Author Topic: Prefab and UIInput/Label questions  (Read 4259 times)

Saxi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 24
    • View Profile
Prefab and UIInput/Label questions
« on: July 29, 2014, 01:07:30 AM »
I have a few issues I'm running into when trying to build a crossword puzzle type of game.

I have an empty game object (Square) which has a gameobject w/  nGUI sprite (uisprite, box collider and UIInput) and another child game object with UILabel).

Screenshot: https://db.tt/s8gUz0Th

Right now I am testing four of these making up a 2x2 grid.  Each square will hold 1 character.

1) How to make the font stay the same size.  I found using Unity font gave me the best results (no gradient, max lines 1).  I tried different settings for overflow and each letter is a different size.  j is big, m are tiny.  Since I am using only 1 character, none of the overflow options really seem to make sense, there is nothing that "do nothing" and leave it be. 

2) Change color of unity font, color tint doesn't work, gradient does if I make top/bottom the same, is that the only way to do it?

3) I made the game objects a prefab, i have the 3 game objects listed above saved as prefab.  But I can't figure out how to do certain things.  Like for example when I change the "overflow" type, and click apply it doesn't seem to affect the other 3 prefabs brought into the scene. 

4) Also with the prefab, I am trying to set submit/change for the UIInput, when I drag the parent game object (that has my script) into submit/change and select my funtions and hit apply to save the prefab, is the game object stored in notify the one I dragged there (thus the same for all four prefab instances) or does it know to use the one for that prefab instance?  The prefab is Square (Parent) Sprite (Child) Label (Child) and the script is on Square (Parent) which would be dragged into Notify on the Sprite UIInput.  I want to make sure it uses the correct Square (Parent) for the prefab's instance.  It appears to (i'm setting a public variable in the script and setting it to whatever is in UIInput to make sure they are all unique).  But want to make sure that is the proper way to do it, or do I need to use code and call getComponent to make sure I get the correct parent object for that particular instance.

5) Is there a way to get sharp crisp fonts with nGUI fonts that would be variable size?  It seems like the Unity native ones are much much sharper.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Prefab and UIInput/Label questions
« Reply #1 on: July 29, 2014, 03:36:46 AM »
Labels must be set to "resize freely" overflow, or you should resize them to fill the entire box.

The area you're providing for labels is too small, so the text shrinks by default when it doesn't fit.

Saxi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 24
    • View Profile
Re: Prefab and UIInput/Label questions
« Reply #2 on: July 29, 2014, 10:40:20 AM »
Labels must be set to "resize freely" overflow, or you should resize them to fill the entire box.

The area you're providing for labels is too small, so the text shrinks by default when it doesn't fit.

I can't use ResizeFreely as I am using an Anchor, I assume clamp is my best bet?

What about the prefab question about notify?   If dragging part of a prefab into Notify for UIInput, will it drag that same gameobject for all copies, or will it know enough to use the gameobject that came with it's prefab?  I assume since it is a prefab, it knows to use it's own copy?

Any way to get the nGUI font to look as good as Unity native?

Is the gradient only way to change the color of Unity native fonts?
« Last Edit: July 29, 2014, 03:55:19 PM by Saxi »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Prefab and UIInput/Label questions
« Reply #3 on: July 30, 2014, 09:47:35 AM »
References within prefabs are only going to be kept if the referenced object is a part of the same prefab. Prefabs are their own self-contained hierarchies.

There are many ways to improve font quality -- use PixelPerfect UIRoot, native font size in labels, ensure everything is pixel perfect (select UIRoot, ALT+SHIFT+P), etc. You will need to be more specific, and pics help.

You can change label's tint color and embed colors, same as any other label, whether it's using dynamic fonts or not.

Saxi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 24
    • View Profile
Re: Prefab and UIInput/Label questions
« Reply #4 on: July 30, 2014, 04:56:15 PM »
References within prefabs are only going to be kept if the referenced object is a part of the same prefab. Prefabs are their own self-contained hierarchies.

There are many ways to improve font quality -- use PixelPerfect UIRoot, native font size in labels, ensure everything is pixel perfect (select UIRoot, ALT+SHIFT+P), etc. You will need to be more specific, and pics help.

You can change label's tint color and embed colors, same as any other label, whether it's using dynamic fonts or not.

Thanks, wanted to make sure the prefabs would behave that way. Good to know.

I couldn't change the color using Color Tint, I changed it to Black and I still have white font.  I could change it with Gradient only.
But then I noticed that if I set the color tint to Black and hit play, I have a white font but I further noticed the color tint was changed to white.  I can change the color tint to any color and the font will change, but for some reason the color tint is changing to white when hitting play.  So whatever I set in the inspector for the label, is no used when hitting play.   Although gradient with black/black seemed to stick.

I made a video showing the behavior: https://db.tt/Srt3YpLC

Is there any visual way to tell quickly if a sprite is pixel perfect already without just clicking UI Root and forcing the tree to pixel perfect?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Prefab and UIInput/Label questions
« Reply #5 on: July 31, 2014, 11:00:35 AM »
UIInput will change the color of the label to the "active" color when you start typing or when it has text in it. Label's starting color is the "inactive" color -- color used when the input field doesn't have any text, or when it's displaying the default text (such as "Press Enter to start typing").

No, there is no way to tell if something is pixel perfect. But if it looks blurry, it's a sign. ;)

Saxi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 24
    • View Profile
Re: Prefab and UIInput/Label questions
« Reply #6 on: July 31, 2014, 11:15:45 AM »
UIInput will change the color of the label to the "active" color when you start typing or when it has text in it. Label's starting color is the "inactive" color -- color used when the input field doesn't have any text, or when it's displaying the default text (such as "Press Enter to start typing").

No, there is no way to tell if something is pixel perfect. But if it looks blurry, it's a sign. ;)

Ahh ok, UIInput was overriding the settings I was making in label.  Thanks!

Anyway to add a feature that would have an icon if something is pixel perfect?  Maybe even an optional gizmo.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Prefab and UIInput/Label questions
« Reply #7 on: July 31, 2014, 12:22:05 PM »
Just because a widget is pixel perfect in NGUI's virtual pixels won't mean that it's actually pixel-perfect when it comes to pixel-to-pixel crispness. Plus to consider pixel perfectness you would need to consider the state of all game objects leading up to your widget. In short, it's not worth the performance degradation and effort. Plus in most cases the UI will be pixel perfect by default, so adding some visualization would mean everything would have it -- not ideal.