This is not really a question, this is an answer for everyone that may have this problem.
(I solved this a minute ago)
It all happened when I was synchronizing my project on a remote server, and opened at the same time the same project in Unity.
When I looked at the scene objects, every script on every GameObject was saying “The associated script cannot be loaded, please fix errors, etc.”.
The project seemed corrupted and I thought I had lost a lot of work.
And, I had no errors, the bar at the bottom said nothing even when I tried to change a script.
Everything was fine before.
The first time I opened a script, I got some weird error about the solution being wrong.
Each time I opened the project, I get a “compiling script” progress bar, that stops in the middle, then opens the project.
If I pressed Play, it said I had to fix the errors.
Don’t touch anything in the project.
In the file manager take the last 1-2 scripts you were working on, and move them out of the project folder.
Reopen the project.
The project should be working fine now.
If you drag again the files on the project (mine was a c# script), it WON’T compile again.
Should be something in that script that the compiler doesn’t like.
Recreate the new scripts from scratch, and add small portions of code copied from the copy you moved away, and try to isolate the lines of the code that seems to cause the issue.
Save the file each time. If you don’t get any errors, may also mean the compiler has crashed.
To be sure everything’s working, run the project.
EDIT: for some reasons, after the crash the console disappeared - that could be the cause of the silent compilation fails.
Make sure to re-enable it from the Window menu.
Try right click on the folder where you keep your scripts or in each individual file and click on “Reimport”, as an alternative click on “Reimport All” on your assets folder but the later can take a few hours in a big project.
the same issue just happened to me. The reason was bcz I’ve renamed one of the scripts(inside Unity) which were referenced in another script.Visual Studio couldn’t detect the issue so just make sure that the files in Unity has the same class name in the Visual Studio.
This just happened to me! Crazy scare! Wow!
Here’s all it is… (As what my understanding is/how I resolved my problem)
For some reason, if you have “compiler errors”, the inspector will NOT load the scripts. (even though we both know they are there, and there are NO problems with them)
But… In MonoDevelop, hit “F8”, and you should see some compiler errors. Fix those, then go back to the inspector, and your problem should be fixed.
At least that’s what I did, and it worked fine.
привет, столкнулся с такой же проблемой. Ошибка была в том, что файл скрипта должен соответствовать названию класса,привет, тоже столкнулся с такой проблемой. Проблема была в том, что имя скрипта в Visual Studio и в Unity отличались. пример RepairInventoryItems и RepairInventoryIteMs
Also, make sure the class in your script file has the same name as the file name.
This happened to me the third time, twice this month… It’s getting out of hand.
The first two times were fixed by just updating the unity, as the process of updating seems to get rid of the problem. But, this time, my Unity is up to date. I’m clueless. I’ve tried NeatWolf’s solution but it didn’t work. I’ve reimported all the assets but it didn’t work. I’ve tried creating a project and assigning some newly made scripts… no. Worse, all of other projects seems to be effected as well… including my backups.
For me, it happened because I had a script with the same class name which clashed with an existing class on a different script. Change the name, and revert all prefabs to their original state… It resets everything.
Bit of an old thread to reply to… :3
I actually had the exact same issue with a project I am working on. In my case, the issue was caused by a script that was presumably created by unity itself. The script was named “RuntimeAlphaMeshCollider.cs” and it appeared out of nowhere inside my script folder. Maybe it was created while exporting but I am unsure. After removing it from the project directory, all of my scrips started working again properly.
Its because the file name and the class in that file should be same eg Script.cs should contain a class with name public class Script : Monobehaviour.
I got this problem due to that
also switching platforms works as well
Had the same problem. In the middle of importing scripts to unity I lost all references. When trying to add personal scripts to an object, Unity didn’t even understand which script was used and instead complained about a random script. Tried restarting, deleting .meta files etc.
I managed to find that one of the scripts I imported used System.IO.Ports. The problem was with comparability for this specific reference. I changed the API compatibility Level in Unity to .Net 4.x from the previous .Net Standard 2.0.
This resolved the incompatibility error, and at the same time fixed the error with all the missing references.
I know im late but I found a new solution to go with before trying everything else since I’ve had this issue a couple times.
It seems like it happens when you close/save a script with an error or Close Unity when one of your script is still having an error.
The solutions I found:
- Comment-out your uncomplete lines of code
- if it does not work, Remove your Script and reimport it to your project (manually CTRL-C CTRL-V if needed)
DO NOT CHANGE ANYTHING IN YOUR UNITY PROJECT!! This just happened to me and it was terrifying. I know this is an older topic but I had to do a little extra work. Reimporting did not work for me. It first happened when I had a compiler error trying to control an animation trigger. It froze up unity, gave me all the script errors, and even on reload wasn’t fixed. I tried deleting some things in unity and had to put them back later hence the initial yelled warning. I “saved as” all my scripts outside of unity in another folder. Deleted all my scripts from the project folder. Deleted the few lines of animator code that caused the initial crash in the single problem script. Then one by one imported the saved scripts to make sure they loaded back in without problems. This problem is scary and confusing but does not destroy your project so don’t panic and remember that your project in unity and your scripts are two different things.
Dont change any thing in your porject if this happen, because is a compille problem. Look for others scripts that you happen did an error without noticed and saved the script without compile it.
I have the same problem, c# script had some errors that was in other script not the one you work on. I found out by opennig all scripts and search for the errors.
If any c# had an error it will not compile any other script. Nor will show where is an error. The compille just stop working.
I did a search in any error in other scripts, corrected the errors and worked fine.