Why does unity not see monobehaviour?
I was working on a game, and everything worked fine, until i restarted Unity and every script said it had no monobehaviour. PLS help!
Answer by lodendsg · Sep 22, 2020 at 03:30 PM
Reasons may be you have spaces in the names of the files or otherwise the name is not exsact ....
"CameraController.cs" is what it should be not "Camera Controller.cs" The name must match exactly ... case and whitespace included. I cant quite tell from your image on my device but that would be the first thing I checked.
Also I strongly recommend you put your classes in a namespace
using UnityEngine;
namespace MyNamespace
{
public class CameraController : MonoBehaviour
{
//.... your code goes here
}
}
the MyNamespace is just an example ... you should generally name your namepsace something unique ... we usually use
namespace HeathenEngineering.GameName { }
Thank you, i found what i did wrong, i missed 1 ; in the code and when i fixed that all code was fine!
Your answer
Follow this Question
Related Questions
Why does unity not see monobehaviour? 2 Answers
How do I fix my UnityEngine Reference? 1 Answer
Can't Add Script "The script needs to derive from MonoBehaviour!" 1 Answer
Attaching sound to ImageTarget issues 0 Answers
Boolean variable is never true, even if declared true or ticked in the inspector 1 Answer