Search Unity

2018.2.3f1 sundenly doesn't reconize monobehaviour

Discussion in 'Editor & General Support' started by PJRM, Aug 12, 2018.

  1. PJRM

    PJRM

    Joined:
    Mar 4, 2013
    Posts:
    303
    I just downloaded the lauched new version 2018.2.3f1 (was using 2018.2.0f2) and when i create a new script, i was able to assign it to a gameobject, however, when i edit it and add a namespace for that class... for organization purposes...
    Code (CSharp):
    1. ...
    2. namespace Game.Components.Map {
    3.   public class NewScript: MonoBehaviour {
    4.     ...
    5.   }
    6. }
    Then the editor do not reconize anymore the script ass monobehaviour to be assigned to a gameobject.

    Anyone/Devs, can tell me if this is a bug or something that i must change in settings to reconize again?

    Edit:

    The error that occur:
    error.jpg
    Here the full script:
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. namespace Game.Components {
    4.    public class MapGeneratorComponent: MonoBehaviour {
    5.       // Use this for initialization
    6.       void Start() {
    7.  
    8.       }
    9.  
    10.       // Update is called once per frame
    11.       void Update() {
    12.  
    13.       }
    14.    }
    15. }
    The script above should be a attachable component for a gameobject.
     
    Last edited: Aug 12, 2018
  2. PJRM

    PJRM

    Joined:
    Mar 4, 2013
    Posts:
    303
    Edit: This really happen... at first i thought it was my mistake, but no. it really happen.
     
    Last edited: Aug 12, 2018
  3. PJRM

    PJRM

    Joined:
    Mar 4, 2013
    Posts:
    303
    Ok... here an example and an image of what is happening:
    error.jpg
    The File is attached.
    Please help.
     

    Attached Files:

  4. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    Are you sure you do not have any other errors in your console?
    If you have errors in your project the file will not compile and unity will say that it can not find any monobehavior in that script.
    Your fist example Script works fine on my 218.2.3f1 (64bit) version.
     
  5. PJRM

    PJRM

    Joined:
    Mar 4, 2013
    Posts:
    303
    No. I insert one space to refresh the script in unity, it work... then i repeat the same action to refresh again in unity and it doesn't reconize the class anymore. This happen time by time. It's not often.
    :rolleyes: i know that. i wouldn't be posting here if the problem was in the console.
    indeed. even with the message saying that the script doesn't have monobehaviour and it is attached to a gameobject, it run perfectly. Crazy, doesn't it? When it happen again i'll record a small video.

    Thank you soo much for your reply.
     
  6. xCerNx

    xCerNx

    Joined:
    Aug 15, 2018
    Posts:
    1
    I have the same problem. Fresh install of Unity and blank project. But I don't even need a namespace. When I restart Unity it will not accept the files at all. I have to reimport scripts every single time.
     
  7. esteban16108

    esteban16108

    Joined:
    Jan 23, 2014
    Posts:
    159
    It happens with only that Component or with all of them? Did you try to change the Class name and the namespace name?
     
  8. PJRM

    PJRM

    Joined:
    Mar 4, 2013
    Posts:
    303
    Most of it solves when i remove completely the namespace.
    So far i have been able to work without a problem (since my last post, but i didn't close Unity at the whole time):p
     
  9. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    1,317
    This looks to be a manifestation of this bug.
     
  10. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    945
    I had the same problem, removing the namespace solves this, but is not the best solution. Unity should look into this issue.