Hello everyone I"ve been working on my an initial game and also suddenly I obtained this error and also cannot operation the game, I currently installed the new version that unity however it persists. I check out it deserve to be resulted in for several reasons but had no luck so far, perform you know the most probable causes and also how to solve it?

When I pick the script the just one whereby I perform not obtain this error is the following:

using UnityEngine; using Assets.Code.States; using Assets.Code.Interfaces; public course StateManager : MonoBehaviour private IStateBase activeState; void start () activeState = new BeginState (this); void upgrade () if (activeState != null) activeState.StateUpdate(); void OnGUI() if (activeState != null) activeState.ShowIt (); publicly void SwitchState(IStateBase newState) activeState = newState; But for instance here I acquire the error:

using UnityEngine; using Assets.Code.Interfaces; namespace Assets.Code.States public course BeginState : IStateBase private StateManager manager; windy BeginState (StateManager managerRef) manager = managerRef; Debug.Log ("Constructing BeginState"); Time.timeScale = 0; publicly void StateUpdate() if (Input.GetKeyUp(KeyCode.Space)) manager.SwitchState(new PlayState (manager)); windy void ShowIt() if (GUI.Button (new Rect (10, 10, 150, 100), "Press come Play")) Time.timeScale = 1; manager.SwitchState (new PlayState (manager)); And so on v every various other script.

You are watching: Unity no monobehaviour scripts in the file

I"ve already installed a newer version of unity3d, uninstalled the antivirus, checked the paper names yet the error persists. I also do not have any kind of class in a namespace..

prize - 1 confirmed
0 arrow_circle_up 0 arrow_circle_down

Make certain your script document is named specifically as the MonoBehaviour course it contains.


using UnityEngine; public course MyScript : MonoBehaviour Also, if your script record contains helper classes, make sure they are inserted on the bottom the the file, never on optimal of the MonoBehaviour subclass.

See more: A Song: Helpmef I Can Be Your Lindsay Lohan I Can Be Madonna Tiktok Trend

Also, unit will sometimes have troubles when your MonoBehaviour classes are in namespaces. I don"t understand when specifically this happens, it simply does every now and also then. Taking the class out the a namespace fixes the error.