- Home /
Unity Lost My Script?
I was debugging in VS Code and when I exited Unity seems to have lost the reference to my script. The script still exists and as far as I can tell it remains untouched (correct namespaces), however, the derived class now says it does not exist?
It appears in Unity as a blank file instead of C#, although when I click it it opens correctly in VS Code. I have tried restarting Unity but it remains missing and I cannot start my game due to the errors. The gameObjects with this script are calling "reference script on this Behaviour is missing". Any ideas how to fix this?
The broken script in question starts with:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EntityMovement : MonoBehaviour
And the derived script has the following:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : EntityMovement
I am also getting spammed with this error message:
Answer by JamieRoss95 · Jan 15, 2020 at 07:28 PM
[SOLVED] I was able to solve this by simply deleting the old EntityMovement file and just making a new one that I pasted all the logic into.
This "solution" seems to work but if anyone has any insight as to why this happened in the first place I would love to know!
It appears that you accidentally renamed the script and removed the ".cs" extension. In older version this used to violently crash Unity, so be glad for small favors :)
That wasn't the issue as far as I can tell. I renamed the file multiple times including the cs extension and that never worked. Only way to get it fixed was to create a brand new script and copy/paste the old code.
$$anonymous$$ight have been a corrupted meta file, but changing the name back and letting it update should have worked, as the meta file are only linked to the filename
Your answer
