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

MonoBehavious Isuues

Discussion in 'Scripting' started by AmiOni, Feb 17, 2019.

  1. AmiOni

    AmiOni

    Joined:
    Feb 17, 2019
    Posts:
    2
    Hello!
    I'm trying to code a dialogue manager, following a tutorial I found online since I'm super new at all this and I keep getting the error message "Can't add script behaviour CallbackExecutor. The script needs to derive from MonoBehaviour!"

    According to the tutorial I'm following, the code is MonoBehaviour, so I'm at a loss. Any help in getting this figured out would be great!

    Thank you so much!
     
  2. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,615
    Did you explicitly indicate that your class inherits from Monobehaviour in the class declaration? The first line after the using statements should look like:
    public class CallbackExecutor : MonoBehaviour {

    If so, then next thing would be to check your spelling and capitalization.

    By the way, you can still write classes that don't inherit MonoBehaviour in Unity, but you always need to inherit from MonoBehaviour if you want to attach your script to a GameObject as a Component.
     
    AmiOni likes this.
  3. AmiOni

    AmiOni

    Joined:
    Feb 17, 2019
    Posts:
    2

    Thank you so much! I relaized what I was doing wrong.