Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Bug Case #1195655: Unity will not recognize a script as MonoBehaviour in specific edge case

Discussion in '2020.1 Beta' started by SugoiDev, Nov 5, 2019.

  1. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    Another MonoBehaviour parser issue. Case #1195655


    This file will break the parser on a11 (at least)

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. namespace RootNamespace.Namespace1 {
    4.     public class BreaksParser {
    5.     }
    6. }
    7.  
    8. namespace RootNamespace.Namespace2{
    9.     public class BreaksParser : MonoBehaviour {
    10.     }
    11. }
    I had never seen this used before, but saw it on an asset store plugin.
    The parser will think this is an invalid MonoBehavior because of the duplicated class name.
    If the Namespace1 class is renamed to something else, it will work.

    Anyone use used that "pattern" before?
    I think the usual is to have only a single namespace per file, but maybe there's a specific reason for doing that?
     
    LeonhardP and Peter77 like this.