- Home /
No Monobehaviour scripts in the file
I am following the Unity tutorial to a T but I am still getting error messages! I am using Visual Studio to input the script but there are no error messages coming up on Visual Studio, only when I get to Unity it comes up with an error message:
'No Monobehaviour scripts in the file, or their names do not match the file name'
This is the tutorial I am following: https://unity3d.com/learn/tutorials/projects/roll-ball-tutorial/moving-player?playlist=17141
I am very confused as to why Unity's own tutorial does not seem to be working so if anyone can help me you would save me a lot of stress!
Answer by MT369MT · Jun 03, 2018 at 07:07 PM
Hi, your script name must be the same as that inside the script. For example in the script you have:
public class PlayerController : MonoBehaviour
The name PlayerController must be the same for the script file inside Unity (in the Project panel in the assets you have probably the C# file with the name that doesn’t match).
ok... so I am an idiot! Thank you so much there was a small spelling mistake on unity - had been focusing all my attention on the code i had written
the day before yesterday it was working fine but now its suddenly not running the project and shows this error I m very much frustrated now
but bro my code is absolutely correct and I checked all spellings nothing is wrong but still I'm getting same error
Answer by wcmclamb7908 · Mar 03, 2021 at 09:51 PM
When I create new C# script, it generates a script which, by default, cannot have its monobehaviour recognized. I'll emphasize this is default script with contents automatically generated by unity and no edits on my part.
In fact, every one of my scripts in this project is now showing as "No monobehaviour scripts in the file".
Your answer
Follow this Question
Related Questions
No Monobehaviour script in the file error Unity 2019.2 2 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Particleellipsoidemitter is missing from Unity 5 library 0 Answers