I just ran into this problem with javascript script. There’s no way to get the classname wrong on a .js script, because the compiler just takes the name of the script as the classname! So I knew that it was something else. In my case, it turned out to be a C# script that wasn’t compiling because of an error. Once I deleted that script, I was able to add my .js script to a gameObject with no problem.
I ran into the exact same problem, however, I had no MonoBehavior/MonoBehaviour spelling issues, the names were in fact identical. It seemed to stem from creating a script from the asset panel. I was following this tutorial:
and when I got to the 2 min mark (I was following the exact click, drap, drop sequence that the tutorial showed) I received the same Class Name Doesn’t Match error.
My fix was to simply restart Unity and it worked fine after that. This leads me to believe that there was some temp file messup on Unity’s part.
Hello guys, i have read all you’re problem’s, and i wanted to help you guys. Read this carefully. First off look at the console and look if there are any errors(if it hasn’t got any errors than look at the last script that you made, that one before the error). Then open the script and (Ctrl + A) copy it and then make a new text folder on you’re desktop(or anywhere as long as you can find it) on the text folder paste the hole script, then save it. Go back to Unity and then delete the hole script(make sure you pasted it on the text folder) and then make a new one (if it’s a C# script make sure to name it the same as you’re last script, the one you coped) paste it in the script and then save it. It works for me.
Actually, it turned out to be that it was a really sh***y error message. It’s been a while, but back then it meant “You can’t add a script to a GO unless ALL scripts compile ok.”