Author Topic: Dynamic UILabel not displaying  (Read 4037 times)

PapaWhiskey

  • Guest
Dynamic UILabel not displaying
« on: January 24, 2013, 02:53:24 PM »
I'm a bit stumped....

I've got a hierarchy of: (first three are straight from ngui)
UIRoot
   Camera
       Anchor (center)
            Panel (more than one)
               Anchor(s)
                   Widget(s)

my panels are attached to gameobjects (basically new "windows") with which I can do NGUITools.SetActive() which gets the whole window "on" or "off"...these gameobjects also have the particular window logic attached via cs script.

one gameObject with a panel attached is one that I've called "labels"...underneath this, I've got another anchor-center (probably not needed), and underneath that i've got 10 UILabels, that are initially set to inactive (i've tried with both nguitools.setactive, and also just setting the active flag on the gameobject) via code.

The code I'm porting has "drawString" routines...i modified the class init function to find the master labels object (works) and find the 10 labels (works)...and I changed the drawString routines to find the UILabel on each gameobject found earlier and then update the labels font, text, color and call MakePixelPerfect, also setting active to true (either method)...

the labels do not show up at runtime, although pausing while running shows that only a handful of labels are active (expected) but there is nothing on them when i zoom in on them, even though clicking on the active label shows that the text,color,font have all updated as expected...additionally the top "labels" panel object says "N" widgets 0 draw calls, even though the panel is active, the anchor is active and the label(s) are active!

already checked color to make sure its in right range, i'm not mucking with scale, etc...can't be the first one to do dynamic labels in this manner, but i'm not finding much searching the forums that wants to help with the issue

edit: if instead of setting active true/false, i just set the text to "" or the string, everything shows up...something about maybe the panel not updating to see that an object is active or not?
« Last Edit: January 24, 2013, 03:31:31 PM by PapaWhiskey »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamic UILabel not displaying
« Reply #1 on: January 24, 2013, 08:09:50 PM »
Why do you have nested anchors?

PapaWhiskey

  • Guest
Re: Dynamic UILabel not displaying
« Reply #2 on: January 24, 2013, 08:40:52 PM »
Why do you have nested anchors?

its just the way it happened...creating a ui using ngui you're given the first three pieces of the hierarchy...i just left it as it was...and added "windows" (panels) that have anchors where i want them...i've also posted that hierarchy in here before and you've answered on it, and not questioned it...and removing that "top" center anchor doesnt change the behavior described in the original post, in case you were wondering.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamic UILabel not displaying
« Reply #3 on: January 24, 2013, 09:08:57 PM »
I am not sure what's happening in your case. If the panel shows 0 draw calls with the labels active, then either the alpha of the labels is 0, or they somehow didnt get enabled correctly (which shouldnt happen since you use the NGUITools activation method). You will have to debug this one.