Egor12 0 / 0 / 0 Регистрация: 18.01.2021 Сообщений: 20 |
||||
1 |
||||
18.01.2021, 14:23. Показов 40135. Ответов 16 Метки unity (Все метки)
Здраствуйте может кто то знает. Я создаю игру на движке unity и у меня ошибка CS0246 можете пожалуйста подсказать как её убрать? AssetsSpawner.cs(8,12): error CS0246: The type or namespace name ‘Gameobject’ could not be found (are you missing a using directive or an assembly reference?) вот такая ошибка.
__________________
0 |
Programming Эксперт 94731 / 64177 / 26122 Регистрация: 12.04.2006 Сообщений: 116,782 |
18.01.2021, 14:23 |
Ответы с готовыми решениями: Как убрать ошибку Как убрать ошибку? Как убрать ошибку? Программа переводит два заданных числа из… ошибка CS0246 в проекте как исправить? 16 |
109 / 81 / 37 Регистрация: 13.01.2016 Сообщений: 395 |
|
18.01.2021, 16:50 |
2 |
Строка 8. GameObject. Вторая часть типа тоже с большой буквы
1 |
0 / 0 / 0 Регистрация: 18.01.2021 Сообщений: 20 |
|
18.01.2021, 16:58 [ТС] |
3 |
Огромное спасибо но теперь ошибка
0 |
74 / 53 / 24 Регистрация: 19.10.2012 Сообщений: 212 |
|
18.01.2021, 18:10 |
4 |
speed += spawner.speedIncrease * Time.deltaTime; Убери spawner speed += speedIncrease * Time.deltaTime; Добавлено через 28 секунд
1 |
250 / 186 / 68 Регистрация: 04.03.2019 Сообщений: 1,010 |
|
18.01.2021, 18:16 |
5 |
spawner.speedIncreas Spawner с большой буквы.
1 |
Egor12 0 / 0 / 0 Регистрация: 18.01.2021 Сообщений: 20 |
||||
18.01.2021, 21:29 [ТС] |
6 |
|||
Спасибо большое, но у меня появилась ещё одна ошибка AssetsDownMover.cs(24,23): error CS1061: ‘Transform’ does not contain a definition for ‘postition’ and no accessible extension method ‘postition’ accepting a first argument of type ‘Transform’ could be found (are you missing a using directive or an assembly reference?) что то я так понимаю с ‘Transform’ не так. буду очень благодарен за помощь.
0 |
74 / 53 / 24 Регистрация: 19.10.2012 Сообщений: 212 |
|
18.01.2021, 21:40 |
7 |
Во первых у тебя с верху написана ошибка. ее в переводчик. Instantiate(Blocklines[rand], transform.postition, Quaternion.identity); все красное ошибки твоего кода. Миниатюры
0 |
0 / 0 / 0 Регистрация: 18.01.2021 Сообщений: 20 |
|
18.01.2021, 22:02 [ТС] |
8 |
Спасибо мне 12 только учусь поэтому у меня столько ошибок ) 2 первые ошибки я уже исправил. А там где postition его просто удалить ? Я не настраивал visual studio под unity потому что не знал что это нужно делать, и не знаю как.
0 |
74 / 53 / 24 Регистрация: 19.10.2012 Сообщений: 212 |
|
18.01.2021, 22:26 |
9 |
Ну Youtube в помощь. Я тоже начал примерно в этом возрасте. Очень давно.
0 |
0 / 0 / 0 Регистрация: 18.01.2021 Сообщений: 20 |
|
18.01.2021, 22:51 [ТС] |
10 |
Спасибо понял. Так всё таки postition убрать из скрипта ?
0 |
74 / 53 / 24 Регистрация: 19.10.2012 Сообщений: 212 |
|
18.01.2021, 23:41 |
11 |
Сообщение было отмечено Egor12 как решение Решение
Так всё таки postition убрать из скрипта ? написано с ошибкой просто. Добавлено через 4 минуты
0 |
0 / 0 / 0 Регистрация: 18.01.2021 Сообщений: 20 |
|
19.01.2021, 10:59 [ТС] |
12 |
Хорошо огромное спасибо ))
0 |
0 / 0 / 0 Регистрация: 18.01.2021 Сообщений: 20 |
|
20.01.2021, 14:28 [ТС] |
13 |
Почему-то speedIncrease работает то есть скорость становиться больше со временем, а Spawner не работает он не спавнит BlockLines.
0 |
Eli_To4Ka 0 / 0 / 0 Регистрация: 23.11.2021 Сообщений: 1 |
||||
23.11.2021, 12:37 |
14 |
|||
Ночью сидел писал код, по примеру ютубера… у него все работает у меня нет… cs0246 ошибку выбивает.
0 |
529 / 341 / 196 Регистрация: 18.10.2019 Сообщений: 1,152 |
|
23.11.2021, 14:13 |
15 |
Eli_To4Ka, interactactable. Правильно — interactable.
0 |
Sovock 0 / 0 / 0 Регистрация: 06.02.2022 Сообщений: 1 |
||||
06.02.2022, 16:13 |
16 |
|||
Делал год из интеренета, всё сделал как на ролике, но появляется ошибка: (AssetsscriptsMovePlayer.cs(49,20): error CS1061: ‘Rigidbody’ does not contain a definition for ‘AddForse’ and no accessible extension method ‘AddForse’ accepting a first argument of type ‘Rigidbody’ could be found (are you missing a using directive or an assembly reference?) вот код:
0 |
529 / 341 / 196 Регистрация: 18.10.2019 Сообщений: 1,152 |
|
06.02.2022, 16:18 |
17 |
Sovock, метод правильно называется AddForce
0 |
I’m trying to make a simple game using unity and C# with vs code. But when I try to build and run the program; it shows «error CS0246: The type or namespace name
‘UnityEngine’ could not be found (are you missing a using directive or an assembly reference?)»
and
» error CS0246: The type or namespace nam
e ‘MonoBehaviour’ could not be found (are you missing a using directive or an assembly reference?)»
I tried to fix the error «preferences -> External tools -> External script editors -> vs code»
but its not work.
But c# works in the random program correctly. When I run any unity scripts; its show error.
code sample in the below:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test : MonoBehaviour
{
public string ab = "sh";
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
Debug.Log(ab);
}
}
Всем привет, дамы и господа! Скопировал я значит код для сохранения данных с одного источника.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
public static class SaveLoad
{
public static List<Game> savedGames = new List<Game>();
//методы загрузки и сохранения статические, поэтому их можно вызвать откуда угодно
public static void Save()
{
SaveLoad.savedGames.Add(Game.current);
BinaryFormatter bf = new BinaryFormatter();
//Application.persistentDataPath это строка; выведите ее в логах и вы увидите расположение файла сохранений
FileStream file = File.Create (Application.persistentDataPath + "/savedGames.gd");
bf.Serialize(file, SaveLoad.savedGames);
file.Close();
}
public static void Load()
{
if(File.Exists(Application.persistentDataPath + "/savedGames.gd")) {
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Open(Application.persistentDataPath + "/savedGames.gd", FileMode.Open);
SaveLoad.savedGames = (List<Game>)bf.Deserialize(file);
file.Close();
}
}
}
Мне выдало ошибку
(10,24): error CS0246: The type or namespace name ‘Game’ could not be found (are you missing a using directive or an assembly reference?)
Честно, я вообще не понимаю сути. Сможете помочь?
Trabla Description:
1. Simple project
2. Script «MyBuildScript.cs» to add custom menu to Unity3d Editor
— compile project for Androdi or iOS
Located in Assets folder
3. Source code of «MyBuildScript.cs» script:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
class MyBuildScript
{
static string[] SCENES = FindEnabledEditorScenes();
static string APP_NAME = «Demo»;
static string TARGET_DIR = «C:\Users\Public\Documents\Unity Projects\demo-buildScript»;
[MenuItem(«Custom/CI/Build Mac OS X»)] // Creates menu item in unity editor
public static void PerformMacOSXBuild()
{
string target_dir = APP_NAME + «.app»;
GenericBuild(SCENES, TARGET_DIR + «/» + target_dir, BuildTarget.StandaloneOSXIntel, BuildOptions.None);
}
[MenuItem(«Custom/CI/Build Android»)] // Creates menu item in unity editor
public static void PerformAndroidBuild()
{
string target_dir = APP_NAME + «.apk»;
GenericBuild(SCENES, TARGET_DIR + «/» + target_dir, BuildTarget.Android, BuildOptions.None);
}
private static string[] FindEnabledEditorScenes()
{
List<string> EditorScenes = new List<string>();
foreach (EditorBuildSettingsScene scene in EditorBuildSettings.scenes)
{
if (!scene.enabled) continue;
EditorScenes.Add(scene.path);
}
return EditorScenes.ToArray();
}
static void GenericBuild(string[] scenes, string target_dir, BuildTarget build_target, BuildOptions build_options)
{
EditorUserBuildSettings.SwitchActiveBuildTarget(build_target);
string res = BuildPipeline.BuildPlayer(scenes, target_dir, build_target, build_options);
if (res.Length > 0)
{
throw new System.Exception(«BuildPlayer failure: » + res);
}
}
}
4. Try to run build script from Editor — menu «Custom» -> «CI» -> «Build Android»
5. Exception:
Assets/MyBuildScript.cs(4,7): error CS0246: The type or namespace name `UnityEditor’ could not be found. Are you missing a using directive or an assembly reference?
Solving:
1. Create folder «Editor» in «Assets» folder
2. Move script «MyBuildScript.cs» to «Assets» -> «Editor» folder
All scripts with using UnityEditor; should be placed in «Assets» -> «Editor» folder
I have SpatialAnchorConfig.cs at the path srcSpectatorView.UnityAssetsSpatialAlignment.ASAAzureSpatialAnchors.SDKScripts
However, get an error:
NullReferenceException: Object reference not set to an instance of an object
SpatialAnchorsUnityBuildProcessing.OnPreprocessBuild (UnityEditor.Build.Reporting.BuildReport report) (at C:/sv/MixedReality-SpectatorView/src/SpectatorView.Unity/Assets/SpatialAlignment.ASA.Editor/Editor/SpatialAnchorsUnityBuildProcessing.cs:108)
UnityEditor.Build.BuildPipelineInterfaces+c__AnonStorey0.<>m__1 (UnityEditor.Build.IPreprocessBuildWithReport bpp) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:376)
UnityEditor.Build.BuildPipelineInterfaces.InvokeCallbackInterfacesPair[T1,T2] (System.Collections.Generic.List1[T] oneInterfaces, System.Action
1[T] invocationOne, System.Collections.Generic.List1[T] twoInterfaces, System.Action
1[T] invocationTwo, System.Boolean exitOnFailure) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:356)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)