Script says compiler errors, but none is shown.

I have a very weird problem. I have two scripts in the scene that give an error “The associated script can not be loaded. Please fix any compiler errors and assign a valid script.” All other scripts work.

Here’s the catch though. Those script have no errors. In fact they are empty except for class declaration. Unity console shows no errors and I can run the scene with only error shown is “The referenced script on this Behaviour is missing!”.

What I have tried to solve the problem so far:

  1. Reboot Unity.
  2. Delete Library folder.
  3. Tried an older version of Unity.
  4. Reboot Computer.
  5. Reimport all.
  6. Unity console does have errors as visible (Working script do give proper output on Debug.LogError()
  7. Most combination of these

Deleting the .meta files will not remove the error, but will mark the scripts as missing. After they are set again the same error persists.

Changing these scripts to another script and back again removes the error until I run the scene and then the error reappears again.

Any ideas on how to solve this would be great.

Check their names. Script name and script class name should be identical.

it also happens when the script name is a keyword

You also get this issue when opening a project from a shared drive.