我对 C# 和 Unity 都是新手。很新。
我创建了一个新的 C# 脚本,并尝试添加以下行:
public Vector3 direction = Vector3.up
当我输入 Vector3 时,我唯一包含 Vector 的选项是“BitVector32”。
我正在 Unity 中使用 3D 对象。
我需要做什么?
编辑:我正在使用以下内容:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
编辑:
intellisense 无法识别 Vector3 sense 它是一种数据类型。它识别“BitVector32”但不识别“Vector3”,当我运行此代码时,一切正常。
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using UnityEngine;
public class Mover : MonoBehaviour
{
// Vector3 is unique to UnityEngine
public Vector3 direction = Vector3.up;
float speed = 0.1f;
void Update()
{
var movement = direction * speed;
this.transform.Translate(movement);
}
}
我会检查您是否已包含
using UnityEngine;
您的 IDE 是否理解其他关键字,例如“Input”或“Application”?如果它无法识别这些,请尝试从 Visual Studio 安装程序安装 Unity Games Development Tools。 此外,Jetbrains Rider 是另一个对 Unity 开发人员非常有用的 IDE。
我可能有点晚了,但我也遇到了同样的问题。对我有用的是进入 Unity,转到左上角并选择“编辑”->“首选项”,然后打开“外部工具”选项卡。其中第一个选项应该是外部脚本编辑器。确保您已选择 Microsoft Visual Studio 20xx。 Intellisense 应该掌握 Unity 特定的对象和数据类型,并能够识别 Vector3 之类的东西。