The referenced script (Unknown) on this behaviour is missing! - how to fix?

SCRIPTS OR ASSETS ARE MISSING OR BLANK

ALWAYS move all Unity assets by using the Unity Editor. Any other way risks disconnecting the GUID in the meta file from the original file, and this will result in all connections to that asset being broken.

Some info about Missing script warnings, broken prefabs, GUIDs, renaming GUIDs, etc:

EVERYTHING in Unity is connected to the above GUID, which is stored ONLY in the metafile, and hence why the metafiles ALWAYS MUST be source-controlled.

When Renaming: It is super-easy to inadvertently change the GUID by renaming outside of Unity. Don’t do that. Instead:

  • close Visual Studio (important!)
  • rename the file(s) in Unity
  • in Unity do Assets → Open C# Project to reopen Visual Studio
  • now rename the actual classes, and MAKE SURE THE FILE NAMES DO NOT CHANGE!

If you are NOT using source control while you do this, renaming files is an EXTREMELY dangerous process. Use source control at all times so that you can trivially revert if you miss a critical step and damage your project.

For future reference:

If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: Using code tags properly

  • Do not TALK about code without posting it.
  • Do NOT post unformatted code.
    - Do NOT attach entire scripts to your post
  • Do NOT retype code. Use copy/paste properly using code tags.
  • Do NOT post screenshots of code.
  • Do NOT post photographs of code.
  • ONLY post the relevant code, and then refer to it in your discussion.