- Home /
Refrencing Monobehaviour in the Editor
Hello everyone. I'm currently watching the "Build Your Own FPS Survival Game" Udamy course. I've done everything the way the instructor said but I keep getting these errors. One script is in Movobehaviour and scripts folder, the other one is in Editor.
Thanks so much for your help.
Unity version: 2020.1.6f1 64bit IDE: VSCODE
in the AIWayPointNetworkEditor it doesn't recognize the AIWayPointNetwork script/class because it is in $$anonymous$$onobehaviour but this one is in the Editor. I think this code used to work in older versions of Unity but I'm using the latest official version but it doesn't work and I don't know what to do....
Answer by Bunny83 · Nov 21, 2020 at 02:43 PM
First of all you should get rid of the duplicated using statement for the System.Collections.Generic namespace as your IDE suggests. You already have this using statement in line 2 so line 4 is redundant.
Next thing is editor scripts and runtime scripts generally live in seperate assemblies. Here it's important to note that Unity will compile your scripts, not VisualStudio. When you create a new script, edit it and saved it, you have to switch to Unity in order for the script to get imported, compiled and to get the VisualStudio solution (and its C# projects) updated.
Answer by MurphyMurph_21 · Nov 21, 2020 at 01:08 PM
@amirhosseinzarei151 you sure you monobehaviour script isn't in the editor folder. Also maybe restart unity
Answer by amirhosseinzarei151 · Nov 21, 2020 at 03:32 PM
OK, guys thank you so much. Everything was fixed. Here's what I did and here's what happened if anyone faces this problem later. Problem: Unity and IDE error while trying to learn Navigation and Pathfinding in "Build your own FPS survival game". Fixes in steps: 1.Got rid of the duplicate code above. 2.Restarted Unity and VScode. 3. Everything crashed. My saved layout was lost. 4. VSCode still gave me errors but they didn't matter because Unity was fine this time and it worked perfectly.
Your answer
Follow this Question
Related Questions
Problem with attaching scripts to objects 1 Answer
Enabling multiple Monobehaviour Components in a game object 1 Answer
No Monobehaviour scripts in files 1 Answer
How do c# scripts get accessed by the Unity Engine 2 Answers
WaitForSeconds() and WaitForSecondsRealtime() negative number concern!!!! 4 Answers