All My Scripts Are Broken - Can't Play Even After I've Removed Them All

Hi all, total newbie to Unity here. I’m starting to learn how scripting works, and I’ve run into a wierd problem. All of a sudden, all my scripts have just… broken. I had just hopped back into Unity after reading something in another window, when the console started spamming me with the error message: “MissingReferenceException: The object of type ‘Object’ has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object.” All my scripts are now flagged as broken, and I can’t test any of them in-game.

This despite the fact that I hadn’t made any changes to the scripts since I last looked at the Unity window, and they had been working fine just a few moments earlier, when I tested them in-game. I tried quitting and restarting Unity, and it seemed to work fine for a while, and even let me run my scripts in-game again. Then I hopped windows again, at which point it gave me the same errors as before. It’s giving these errors (and stopping me go in-game) even if I remove all the script components from every object in my scene.

I can’t understand what’s gone wrong. Is this a bug, or am I just such a bad coder that I managed to break Unity itself?

Sounds like one of those things where nobody can help you without knowing every detail ever.
Though… what version are you using? And have you recently upgraded? Any editor scripts? That’s anything that’s running while in editor, so everything from custom windows/inspectors to the [ExecuteInEditMode] attribute. Perhaps something from the asset store?

Try restarting the app or your computer (believe me, this has fixed unity before). Otherwise, you might have an editor script that you deleted something of.

Aaaaah damnit, I’m an idiot. My scripts really were full of errors. Now I’ve fixed them I’m having no trouble whatsoever.

I can see I have a bright future in programming ahead of me…

1 Like