Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Unity 2018.3 is now released.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Can't add script to object in Unity 2018.1.0b8.

Discussion in 'Linux Editor' started by u_rs, Feb 24, 2018.

  1. u_rs

    u_rs

    Joined:
    Jan 5, 2016
    Posts:
    147
    It says:
    Can't add script behaviour VisualContainerAsset. The script needs to derive from MonoBehaviour!

    Also in console:
    Assertion failed: Reentered BeginCurrentContext
    UnityEngine.GUIUtilityProcessEvent(Int32, IntPtr)


    This is beginning of my script:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5.  
    6. public class AddButton : MonoBehaviour {
     
  2. spawn9

    spawn9

    Joined:
    Mar 19, 2018
    Posts:
    1
    i've this problem too if you have a solution pls help me
     
  3. u_rs

    u_rs

    Joined:
    Jan 5, 2016
    Posts:
    147
    I use unity-editor-2017.2.1f1 now and had such problem there, but after I reopened the editor the problem seems disappeared.
     
  4. SAAARGE

    SAAARGE

    Joined:
    Oct 5, 2015
    Posts:
    2
    I'm using Unity 2018.1.0f2 Personal, and I'm also getting this error using :

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3.  
    4.     public class HUDController : MonoBehaviour
    5.     {
    I'm not getting the Assertion failed message however. Anyone with knowledge on this, please share with us! I would be eternally grateful, as I have deadlines. Updates keep causing us to have backtracks.
     
  5. knobby67

    knobby67

    Joined:
    Aug 30, 2015
    Posts:
    317
    I had this issue. Last time I updated .b8 I think. What had happened unity or linux make I my scripts lower case, so for example I had hudcontroller.cs but still the class was HUDController.
    It was an absolute pain but I had to rename by hand.


    Another I can think of is if your class name matches a unity class ( I think ) Try renaming the script with to say HUDControllerTest and do the same for class
     
  6. legrandtimonier1951

    legrandtimonier1951

    Joined:
    May 28, 2018
    Posts:
    4
    I have just installed Unity 2018.1.1f1 and get the same ... script must derive from MonoBehaviour message when trying to attach this script to a gameobject:

    using UnityEngine;
    using System.Collections;

    public class Text1 : MonoBehaviour {

    // Use this for initialization
    void Start () {
    Debug.Log ("Start");

    }

    // Update is called once per frame
    void Update () {

    }
    }

    I thought it might have to do with my Visual Studio editing environment, but checking Edit > Preferences > External Tools and having installed WinMerge. Another thing I should point out is that the above test program won't complile in VS even though it's so simple nothing can be wrong with it. Or am I mistaken? Can someone help point me in the right direction so I don't waste any more time trying to figure out what must be a tiny problem?
     
  7. ThomasWigley

    ThomasWigley

    Joined:
    Oct 7, 2017
    Posts:
    1
    Ever since upgrading to Unity 2018.1, I have had these problems too. I have tried endlessly referencing and adding extra game objects for GUI Text, watched the tutorials and I keep getting this Error. I frequently get ' must derive from mono behaviour ' issue on 90% of created scripts in the Unity Editor and am thinking of going back to 2017. Can anyone help PLEASE.
     
  8. JomppupomppuX

    JomppupomppuX

    Joined:
    Nov 18, 2018
    Posts:
    2
    I have the same problem, when taking a script from tutorial assets too.
     
  9. senkal_

    senkal_

    Joined:
    May 22, 2018
    Posts:
    26