In my current project, when I add a UI object (e.g. by GameObject > UI > EventSystem) it gets initialized without scripts.
I therefore get errors which say “The referenced script on this Behaviour is missing!”, but I cannot select them because they are not in my Assets folder.
The problem doesn’t occur when I start a new project, which leads me to believe something went wrong when I cloned the current project from a repository.
I’ve got the idea the problem has to do with locating UnityEngine.UI.dll, but how can I tell the Unity project where to look for it?
We had an issue with a couple of people in our company, I believe its caused by having multiple instances of Unity installed somehow, those of us who only have one Unity installed (because each instalation we override the previous) never had that issue. and when one of us had the problem uninstalling an unused version of unity fixed the problem.
I don’t have an answer for this, and I couldn’t find a solution. It happened 3 times, for no apparent reason, with medium sized scenes, and boy, was it a nightmare to string everything together again.
I realized what catastrophe it would be if it happened in a huge game with 10-20 levels…imagine a game you’ve been working on for 2 years day and night…it would take you at least months to fix.
Anyway, I realized that I can’t use trust the editor anymore, so I simply set everything up in code. Not the best “solution” but what else to do ?
My particular case of UI components missing script references only occurred in Xcode (not Unity editor) and involved the use of Asset Bundle Variants.
I found that Unity-authored scripts (e.g. Canvas, Canvas Scaler, Graphic Raycaster, Image) that are not used in the bootstrap scene cannot be loaded in the variant scene when running on iOS via xCode. You get a “The referenced script on this Behaviour is missing!”. There is also a corresponding message that does indicate the Unity Game Object whose Unity-authored script cannot be loaded, but I’m documenting this after I found a resolution and don’t recall the message. I encountered this scenario for GUI components: Canvas, Panel, Image, EventSystem.
To resolve this, I created a dummy GUI component in the bootstrap scene for each GUI component that I use in the variant scene and made them non-visible by settings their sizes to 0. It’s interesting that Unity has no issue loading scripts I author in the variant scene which are not present in the bootstrap scene, but somehow can’t do this for its own scripts.