No Monobehavior scripts in the file error after trying to rename a script.

I tried to rename a script file name rather than recreating it.

Now I have an issue where all of my scripts say in the editor “No MonoBehavior scripts in the file, or their names do not match the file name”.

I suspect the Unity generated files and reference numbers (guid’s) now don’t match the .meta numbers for my .cs scripts.

Is there anyway to reimport all my scripts without recreating the entire project?

Or is another issue causing this? I’m quite sure there is nothing wrong with the scripts themselves as they were all working prior to me renaming the one script file.

Script filenames need to match the name of the class defined within them. So if you changed MyScript.cs to MyNewScript.cs, you also need to change public class MyScript : Monobehaviour to public class MyNewScript : Monobehaviour

I have solved this issue.

One of my scripts had a compiler error. Seems this can block the editor from recognizing new scripts but also the console posting the compiler error (possible bug).

I only realized when I deleted all my scripts and re-added them one by one to the project.

This happened with me recently. I know this must have already been solved for you but I just thought I’d spread word that I fixed it by making a blank script with the same name as the old script, then deleting the blank script.