Can't Add Script "The script needs to derive from MonoBehaviour!"
So I'm working my way throught the 2D Rogue-like Unity tutorial. When I try to add a script to one of my game object I get the: "Can't add Script behaviour. The script needs to derive from monobehaviour! " error.
The object is GamerManager, and I tried to add a GameManager.cs script, as per the video.
I'm using MonoBehaviour, it's in the script. I followed the tutorial to the letter. I even tried using the code from the Unity web page and I keep getting the same message.
Cheers!
 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;       //Allows us to use Lists. 
 
 public class GameManager : MonoBehaviour
 {
     public static GameManager instance = null;              //Static instance of GameManager which allows it to be accessed by any other script.
     private BoardManager boardScript;                       //Store a reference to our BoardManager which will set up the level.
     private int level = 3;                                  //Current level number, expressed in game as "Day 1".
     //Awake is always called before any Start functions
     void Awake()
     {
         //Check if instance already exists
         if (instance == null)
             
             //if not, set instance to this
             instance = this;
         
         //If instance already exists and it's not this:
         else if (instance != this)
             
             //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
             Destroy(gameObject);    
         
         //Sets this to not be destroyed when reloading scene
         DontDestroyOnLoad(gameObject);
         
         //Get a component reference to the attached BoardManager script
         boardScript = GetComponent<BoardManager>();
         
         //Call the InitGame function to initialize the first level 
         InitGame();
     }
     
     //Initializes the game for each level.
     void InitGame()
     {
         //Call the SetupScene function of the BoardManager script, pass it current level number.
         boardScript.SetupScene(level);
         
     }
     
     
     
     //Update is called every frame.
     void Update()
     {
         
     }
Answer by ryuholy749 · Feb 05, 2019 at 04:56 AM
I'm sorry if this doesn't help you, but I'll post this in case it helps someone else who shares our pain XD. I too had this problem, but I was able to resolve it by making my class name in the script and the script's file name the same (I had put a space between "Game" and "Manager" in the filename) It looks like your's are the same, but I hope that helps someone!
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                