Unity cannot find scripts after downloading from github...no luck with other fixes

I am at my wits end…recently had a computer harddrive crash, so I had to reimport my github project…I apparently didn’t upload my meta files so I noticed a bunch of scripts needed to be fixed…no issues, I’ll just put the scripts back on the game objects etc…

Except I take a closer look and I am getting the messages:

“The associated script can not be loaded. Please fix any compile errors and assign a valid script.”

And on the script itself I also get:

“No MonoBehaviour scripts in the file, or their names do not match the file name.”

Except they absolutely do match—everything matches, this was all working without issue until the crash.

Then I notice that half of my scripts are no longer recognized by Unity at all…they are in the same place as I left them and everything was workign fine the last time I attempted to run it prior to the harddrive issue.

When I go to add new script, it only shows me a few of my scripts instead of all of them…all of the ones that are saying they can’t be recognized are not there if I try and add a component, choose script and then it gives me a list of scripts…

It has nothing to do with the script name not matching the class name, again they are all named properly and were working fine…the scripts are there but somehow unity has decided they are no longer valid…

I tried doing what I have found that worked for some in other threads—here is what I have attempted so far with no luck:

  • delete all the meta files
  • move scripts out of the directory and then move them back—this seems to work for a split second but then it goes back to saying the same thing
  • delete the cs project files
  • rebuilt the project in Visual Studio which rebuilds without issue…
  • delete the library directory

I am at a loss of what to do…I try and create a new script and copy over the contents of the old script but that doesn’t work either…it still tells me the script isn’t found.

Specifically, it appears to be scripts that are using namespaces, but even if I remove the namespace it still doesn’t find it…

Please help!

The scripts shown in the inspector and adding components to objects is not going to work correctly if Unity believes there are compile errors. None of that works properly until Unity can compile all of your scripts, so stop trying to make that part work, and in fact ignore anything the inspector says until then. You should be focused on fixing the errors specifically reported by the console. After those are cleared up then you can start messing with adding the scripts back to gameobjects.

I had programs working literally yesterday… SAME thing… re-installed Unity… same version… loaded my SIMPLE of SIMPLE scripts… like…basic 4way player movement stuff…real straight forward… but no way they will work… VERY frustrating and such a waste of time. :frowning:

I would love an answer for this problem too… looking on Google… this seems to trail back to 2010!.. across many versions… I can’t find an answer… I know I am a beginner… but I have tried everything the OP tried to no avail. At this point I am considering just going back to Unreal4, shame as I like Unity’s IDE.

FWIW same is happening trying to open a 2017.30f2 in a just installed 2018.1.1f1.
So far no scripts at all are working, even certain prefabs based on custom LAS->mesh importers are not working.