我试图在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和monobhavior,都加了下划线,并显示相同的“找不到命名空间”错误,就像它们不在这个命名空间中一样。那么,我如何定义名称空间导入以正确运行代码呢?
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