Search Unity

Is setting a gameobject's name to null allowed?

Discussion in 'Scripting' started by rawegames, Oct 21, 2016.

  1. rawegames

    rawegames

    Joined:
    Aug 1, 2016
    Posts:
    91
    C#,
    Via scripting, I can set a gameobject's name to "" or string.Empty or null, err, right?
    Is null allowed?
    How about tags?
     
    Last edited: Oct 21, 2016
  2. Piflik

    Piflik

    Joined:
    Sep 11, 2011
    Posts:
    292
    The name property of Gameobject has the NotNull attribute and setting it to null will result in it being automatically set to an empty string.

    The tag can be set to null, but will throw a NullReferenceException.
     
  3. AdmiralThrawn

    AdmiralThrawn

    Joined:
    Dec 1, 2013
    Posts:
    18
    jdmozo likes this.
  4. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,508
    Legends say he took the full two years to bring them this answer.