【发布时间】:2018-05-19 17:33:00
【问题描述】:
我正在尝试在 Visual Studio 中运行简单的 Unity 脚本(作为我的对象的一个组件附加)。代码如下:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class BlackPawnParticleSystem : MonoBehaviour {
// Use this for initialization
void Start () {
ParticleSystem ps = GetComponent<ParticleSystem????);
var em = ps.emission;
em.enabled = true;
em.SetBursts(
new ParticleSystem.Burst[]{
new ParticleSystem.Burst(2.0f, 100),
new ParticleSystem.Burst(4.0f, 100)
});
}
// Update is called once per frame
void Update () {
}
}
问题是当我运行它时出现错误:“找不到命名空间或数据类型 NavMeshAgent”。我读过简单的 UnityEngine 导入可能存在问题。所以我把它换成了using UnityEngine.AI。
但是像 ParticleSystem 和 MonoBehavior 之类的所有类都带有下划线,并显示相同的“找不到命名空间”错误,就像它们不在此命名空间中一样。那么如何定义命名空间导入以正确运行代码?
更新:完整的错误信息是
D:\userdata\Documents\Scene1\Assets\RPG Character Animation Pack\Code\RPGCharacterControllerFREE.cs(21,10,21,22): error CS0246: Can not find namespace or data type NavMeshAgent
【问题讨论】:
标签: c# visual-studio unity3d namespaces