Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: John.Bergman on December 29, 2013, 06:11:51 AM

Title: NGUI 3.08 UILabel.color is broken when accessed from a script
Post by: John.Bergman on December 29, 2013, 06:11:51 AM
I created a Panel, and placed a UILabel it in.  Then I created and attached the following code below, when it runs, I can see the color change in the inspector, but the label is not rendered (it disappears).  Is this a bug, or am I missing something?  if I comment out the setting of the color, the label text changes.


-=-

public class FloatingText : MonoBehaviour
{
  public Color TextColor=Color.blue;
  public string Text;

  private UILabel m_Label;

  void Awake()
  {
    m_Label = GetComponent<UILabel>();
    if (m_Label == null)
    {
      Debug.LogError("Unable to find UILabel for floating text");
    }

  }

  void Start()
  {
    if (m_Label != null)
    {
      m_Label.color = TextColor;
      m_Label.text = "New Text";
    }
  }
}
Title: Re: NGUI 3.08 UILabel.color is broken when accessed from a script
Post by: ArenMook on December 29, 2013, 06:05:25 PM
I did the following:

1. New scene.
2. ALT+SHIFT+L to add a label.
3. Attached your script to hit, entered text "Testing".
4. Hit Play.

The label is still visible, now in blue color, and its text is now "Testing". What is different on your end?
Title: Re: NGUI 3.08 UILabel.color is broken when accessed from a script
Post by: John.Bergman on December 30, 2013, 08:56:06 PM
Not sure, I'll play around with this some more to see if I can get it working; if not, I'll post again... I have since moved on to work on some different things.

As an aside, have you thought about updating your Tnet to include a NGUI based chat applet.. that would be a good demo  ;)

Title: Re: NGUI 3.08 UILabel.color is broken when accessed from a script
Post by: ArenMook on December 31, 2013, 04:31:36 AM
Starlink UI kit includes an NGUI-based chat window. Using TNet for chat is a trivial thing. You can mod the chat example that comes with NGUI to do an RFC in its submit logic. As long as the TNObject is present on the chat window, everything will sync as expected.