Author Topic: UILabel.text=null not resetting v2.1.6  (Read 3617 times)

TomA6

  • Guest
UILabel.text=null not resetting v2.1.6
« 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel.text=null not resetting v2.1.6
« Reply #1 on: September 14, 2012, 05:21:29 PM »
Hmm. I'll have a look at that, thanks.