Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Chris_E on May 09, 2013, 10:35:10 PM

Title: Font Questions
Post by: Chris_E on May 09, 2013, 10:35:10 PM
Hi!

I have two questions about fonts/labels.

First, I'm using the dynamic font that was recently added.  Is there an easy way to make the font and label have the same depth position?  I have five boxes, and each box has text, and they're all draggable.  Sometimes a box will be in the back, but its font is in the front.

Second, is there a way to make a label the child of a sprite?  It would be a lot easier to move them around, and tell which label is for which box if I could just have the label as a child.  If I remove the code to make them auto-remove will having a label as a child of a sprite cause problems?

Thanks,

Chris
Title: Re: Font Questions
Post by: ArenMook on May 10, 2013, 12:14:52 AM
Font has no depth. Font is a data class. I don't understand what you're asking.

When using dynamic fonts on labels, depth won't work. Consult the FAQ or the "adjusting depth does nothing" sticky for more info. Two sticky posts, and I still get the same damn questions...

No, you can't nest widgets. Shit hits the fan when you do due to how Unity combines the scaling component. Widgets need to have a common game object parent with a scale of (1, 1, 1).
Title: Re: Font Questions
Post by: Chris_E on May 10, 2013, 01:57:23 AM
Hah!  I understand the sticky, and I'm asking for a way around the issue of mixing the use of depth for my sprites with z for my labels... let me try to explain better:

I have 6 sprites which are all draggable.  Each of these sprites has a label associated with it, when the sprite moves the label moves.

So let's say I have the sprites with depth of 0, 1, 2, 3, 4, 5.  Is there an easy way to get the label's z to match?

It would be easy if the label was the child of a sprite... I could just find the parent, get the depth, and make that (-0.01 to make sure the text is on top!) to the label's z value.

Any suggestions?

(To sum up:  Depth IS working on the sprites... and I want to match that with my fonts.  Or maybe turn off the depth for the sprites, so I can just use their Z position?  Anything to get the font not to show through!)
Title: Re: Font Questions
Post by: Nicki on May 10, 2013, 06:32:21 AM
Put the label and sprite in a common parent with a UIPanel on it, then you can set the z localposition on that panel to get them to layer nicely.

Alternatively, you have to make a custom script that makes the label's z and the sprite's depth correlate every update or so (or every time you change one of them).