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

Namespaced MonoBehavior script?

Discussion in 'Scripting' started by Deleted User, Aug 21, 2018.

  1. Deleted User

    Deleted User

    Guest

    This may a noob question, but to me feels natural to use namespaces everywhere but seems that I cannot put a monobehavior in a namespace and them attach to a gameobject in the editor.

    Capture.PNG

    As you can see above unity is not able to see the mb if inside a namespace, if I remove the ns it works, also theres no errors in the project, is just a blank new project with just this file.

    Regards

    Edit: Fixed screenshot
     
    Last edited by a moderator: Aug 21, 2018
  2. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    Try adding a space after NamespacedClass and before the colon.
     
  3. Deleted User

    Deleted User

    Guest

    Cool it worked, thanks!

    Wow, is that serious? Besides it worked perfectly, how is this bug editor still here? I read that namespaced mb was introduced in Unity 4.1
     
  4. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    There have been a few threads recently around this issue of the parser. There are a few quirks currently in Unity's implementation. Some have been addressed recently but others, including this one, remain. The space should not be necessary but, for the time being, just is. :)
     
  5. Deleted User

    Deleted User

    Guest

    The space issue is fixed in the latest, Unity 2018.2.5, according to the release notes (I haven’t tested it, yet).