Reputation: 3099
I am trying to run simple Unity script (which is attached as a component of my object) in Visual Studio. Here is the code:
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 () {
}
}
The problem is that when I run it I get an error: "Can not find namespace or data type NavMeshAgent". I have read that there might be a problem with simple UnityEngine import. So I have replaced it with using UnityEngine.AI
.
But all the classes like ParticleSystem and MonoBehavior are underlined and show the same "Can not find namespace" error like they are not in this namespace. So how I can define my namespaces imports to run the code properly?
UPDATE: full error message is
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
Upvotes: 2
Views: 2722
Reputation: 182
Don't remove the UnityEngine
import, just add the UnityEngine.AI
import on the next line.
using UnityEngine;
using UnityEngine.AI;
You'll have to add this import to the actual file that is giving the error, so in this case that means you need to go to RPGCharacterControllerFREE.cs
and add using UnityEngine.AI;
to that file.
Upvotes: 2