Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: TomA6 on September 14, 2012, 05:20:22 PM

Title: UILabel.text=null not resetting v2.1.6
Post by: TomA6 on September 14, 2012, 05:20:22 PM
Something I noticed when switching my Unity GUIText's over to UILabel.

  1.  guiLevel =  GameObject.Find("level").GetComponent<GUIText>();
  2.  
  3.  public void ResetStatus()
  4.  {
  5.     guiScore = guiHealth = guiLevel.text = guiGoal.text = null;
  6. ...
  7.  

The above used to wipe out all text boxes under GUIText. If I set text = null on a UILabel it will not change it's state. One usage for this is to Hide Text Messages that would otherwise be displayed on screen. If null is set your last Text Message will still be on screen.

If you set it equal to "" that will fix it but that may impact your other place holders if your game is expecting a null.
  1.  guiLevel = GameObject.Find("level").GetComponent<UILabel>();
  2. // guiLevel =  GameObject.Find("level").GetComponent<GUIText>();
  3.  
  4.  public void ResetStatus()
  5.  {
  6.     guiScore = guiHealth = guiLevel.text = guiGoal.text = "";
  7. ...
  8.  

Not that this causes any trouble for the most part. Just thought to point out one difference when switching from Unity's GUIText to UILabel if that helps.
Title: Re: UILabel.text=null not resetting v2.1.6
Post by: ArenMook on September 14, 2012, 05:21:29 PM
Hmm. I'll have a look at that, thanks.