Hi,
I am just starting to learn Unity (just yesterday) …well “trying” to start learning until i got this annoying error.
I just create a C# script in a new project and right from the beginning i get hit by a “all compiler errors need to be fixed …bla bla bla”
even though the project is freshly new, no other scripts are there only this new one. the error keeps popping. if i delete the script everything goes fine. i try creating a new one and the problem appears again. i searched for two straight days for a fix with no results. so far i tried doing this :
made sure the name of the class and the name of the file are exactly same (lower upper case included). keep in mind this happens even if i just click create script with no change.
did the refresh reimport all from the assets menu.
delete all projects and reinstall unity again.
disable antivirus software
restart windows over and over
restart unity and try deleting all projects and documents and create fresh ones.
tried both monodev and visual studio both show no errors in the script.
I am running the latest version of unity (5.6) on windows 10 with latest updates.
Would really appreciate the help on this one. its driving me crazy but i am really into learning this thing.
I think I should add that When i check the console for errors i just find one single red exclamation mark with no text or details. I try to click on it and nothing happens. Try to clear console and nothing happens the red mark is still there
Thanks for the reply!
Though like i said its the default template that is created when you create a new script file. Anyway below is the script (note that i made sure the class name is exactly as the file name)
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
void Start() {
}
void Update() {
}
}
@shebli7 recently this started happening to me. I was thinking it was a bug with Unity 2018.26 or some how a bug between an interaction with VS2017 and Unity 2018. I reimported my program and the error went away. However, whenever i added a new script the error would come back.Then I noticed an extra “;” in one of my programs and removed it. The error went away permenately. Hope this helps anyone else who finds this.
I had the same problem using 2019.3 . So I copied contents of the script to Notepad. Deleted the script and created a new one. When I pasted the script back from Notepad the problem happened again. So I then cleared the script and pasted back from Notepad one line at a time and it worked!
I tried this several times and am convinced there is some hidden formatting which was corrupted.
So if you have this I would first try copying everything out to clear your script, then paste back line by line checking each time.
After updating from Unity 2020.3.7f1 Unity 2020.3.6f1 I had the same problem. None of my scripts using Monobehaviour found that class.
Microsoft Visual Studio Community 2019, Version 16.9.4
I have 20+ scripts in my project.
I just added a new (empty) script file via the Unity Editor and that fixed the problem. Now the code builds fine. I could remove the empty C# script file and everything still was working.
I think this must be a bug. A missing reference or confused metadata file.
That’s not updating, that’s downgrading. And Unity doesn’t support any form of it. You always need to revert your project in your version control system or load back a backup. And as the update alert dialog says always backup your project before you update it to a new version. It is not a joke.
Open Edit->Preferences->External Tools change the external script editor back and forth and then click “Regenerate Project Files”
that was the thing that worked for me
Hey everyone, so I actually tried all the above solutions and none of them worked. But what did work for me was simply going checking the Unity extension in the VSCode Extensions tab, and enabling it for the current workspace. After you enable it, a popup should appear on the bottom right asking you to restart the language server, and once you do your references will now be found.