Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity not detecting MonoBehaviour

Discussion in 'Scripting' started by Hopeijay, Jun 20, 2020.

  1. Hopeijay

    Hopeijay

    Joined:
    Sep 13, 2019
    Posts:
    8
    I was making this script:
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class slowmoask : MonoBehaviour
    4. {
    5.    
    6.     public bool slowmobool;
    7.    
    8. }
    However, when I try and add it to an object, it says it can't find a MonoBehaviour class and tells me to check for compiler errors and make sure the filename is the same as the class name. Both Unity and Visual Studio say there are no compiler errors and I checked and the name is the same as the class name. The same error then happened to my other already made scripts. I tried remaking the scripts and even restarting Unity, the same error still there. I had recently updated to the most recent version and I made this project in that version. I thought it may be a glitch with the most recent version, so I downloaded the project to the second most recent version and it still didn't fix it. Am I doing something wrong? Does anyone know how to fix this? I thanks if you can help.
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,890
  3. Hopeijay

    Hopeijay

    Joined:
    Sep 13, 2019
    Posts:
    8
    I thought it may be that, I have a script that looks for that public bool, and without that script with the bool on the object, it can't find it. I will try commenting out the other script and seeing if it works. Thanks!
     
  4. Hopeijay

    Hopeijay

    Joined:
    Sep 13, 2019
    Posts:
    8
    For any others with this problem, PraetorBlue is correct and follow what they said.
     
  5. Hopeijay

    Hopeijay

    Joined:
    Sep 13, 2019
    Posts:
    8
    That worked, thanks!