Search Unity

Does Unity have a hidden root namespace var/unicode when undefined by user?

Discussion in 'Scripting' started by BLANKSLATE0, Feb 26, 2022.

  1. BLANKSLATE0

    BLANKSLATE0

    Joined:
    Aug 22, 2020
    Posts:
    7
    This is purely for curiosity.

    If you try to place a script directly inside Assets/Scripts, without a root namespace defined by the user in settings, according to Rider the root namespace should be " or removed

    I was thinking maybe Unity is using a special zero width unicode for the default namespace

    Some history about DNS tells us the root address of the internet is ""

    I was wondering if Unity was doing something similar.
     
  2. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    3,998
    First of all Unity does nothing special when it comes to compiling the C# code since it uses the default mono compiler. Second namespaces are a pure organisatorial tool. Types / classes which are in no explicit namespace are in the global namespace.

    You may want to read about namespaces here and about the global namspace here. So if you want to explicitly want to access something in the root namespace, you would use the root namespace alias
    global::