Author Topic: UIGrid dynamic buttons with labels.  (Read 5811 times)

Melcid

  • Guest
UIGrid dynamic buttons with labels.
« on: April 21, 2012, 01:55:22 PM »
I just bought the NGUI.
I've spent the last 3 hours struggling with this issue and could really use some help.

I'm trying to create a dynamic list of buttons. Its mostly working, but the labels inside of the buttons refuse to sort correctly.
I am using NGUITools.AddChild, and adding them to a grid, all of that works, except the sorting, I've tried adjusting the depth, it does nothing, I can see my text is behind the sprite if I move the text to the edge.


Edit: Also if I disable Clipping on the panel the text appears.
« Last Edit: April 21, 2012, 01:58:38 PM by Melcid »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIGrid dynamic buttons with labels.
« Reply #1 on: April 21, 2012, 01:58:25 PM »
Are you using a different atlas for your labels? See the second post in the FAQ: http://www.tasharen.com/forum/index.php?topic=6.0

Melcid

  • Guest
Re: UIGrid dynamic buttons with labels.
« Reply #2 on: April 21, 2012, 02:00:37 PM »
I cant adjust the Z depth, it keeps resetting it in the label inside the button.

Melcid

  • Guest
Re: UIGrid dynamic buttons with labels.
« Reply #3 on: April 21, 2012, 02:01:51 PM »
Is there somewhere I can adjust the depth for a given atlas?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIGrid dynamic buttons with labels.
« Reply #4 on: April 21, 2012, 02:10:18 PM »
Only the Z scale gets reset, position gets rounded instead. I just tried it here to double-check. The button has a script on it by default UIButtonOffset -- that one adjusts the position, but it defaults to the button itself. There is no reason your label transform's Z wouldn't be adjustable.

You don't set depth or Z on the atlas, only on objects in the scene. Think of the atlas as a big texture. Does a texture have a position? Nope, but if you place an object using that texture into the scene, the object does. Same thing here.

Melcid

  • Guest
Re: UIGrid dynamic buttons with labels.
« Reply #5 on: April 21, 2012, 02:19:10 PM »
ah, I didnt realize it was rounding it.

it appears to be mostly working now.
the only problem I see is that the text when not completely clipped out of view appear black where they shouldnt be visible at all.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIGrid dynamic buttons with labels.
« Reply #6 on: April 21, 2012, 05:57:12 PM »
Black? Can't say I've seen things appear black. Everything completely outside of the clipping area gets clipped and won't get drawn. If you don't have shaders enabled (GLES 1.1 emulation turned on), then everything inside the clipped area will look like it's made out of blocks instead.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: UIGrid dynamic buttons with labels.
« Reply #7 on: April 21, 2012, 07:28:03 PM »
If you have shadow or outline on your text and you soft clip it, it will fade towards black because of the way the effects work. It will have 1 (shadow) or 4 (outline) colored labels underneath the main label in the color of your choosing, so if you have white text with black outline, it will fade towards black.