Author Topic: UILabel  (Read 151829 times)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel
« Reply #30 on: February 13, 2014, 03:21:49 AM »
D) http://www.tasharen.com/forum/index.php?topic=6758.0

Although generally I'd suggest using a prefab for what a single row would look like, and instantiating it multiple times under a UIGrid (and changing the content on that row as necessary)

Denis

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UILabel
« Reply #31 on: February 13, 2014, 04:20:30 PM »
I tried using a Row Prefab with a UIGrid, and it certainly works but I am concerned about performance and memory. That's a lot more GameObjects and Components.  It would make sense if I was doing a special screen, but I am trying to use this for debug text that I don't want to impact the framerate.  It would be more efficient (and faster to implement) if I could use a single UILabel component.

I suspect option 'C' may be not too bad, since just need to hook into where it computes glyph offsets.


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel
« Reply #32 on: February 14, 2014, 06:11:00 AM »
Having a few extra game objects won't give you any noticeable performance changes. Once you hit like 10,000+ game objects... then start worrying. Also if you're truly worried about minimizing everything, you can just have a paged approach where you load only a few rows at a time. I did that in Starlink -- I only load rows that are close to the player's score.

Denis

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UILabel
« Reply #33 on: February 14, 2014, 12:04:27 PM »
True, but am thinking more implementation time or hassle. If you're just trying to implement something quickly, such as on-screen debug text, it's a lot faster to do it with one UILabel. The following would be similar to how tabs (\t) work where [+100] jumps to 100 pixels from left of element.
1) add UILabel object
2) add code that outputs something like "value[+100]value[+200]value\nvalue[+100]value[+200]value"

Compare to with a UIGrid and row Prefab.
1) add a Prefab GameObject
2) add one UILabel per column, with appropriate dimensions
3) add UIGrid object
4) add code that looks like:
* AddChild(prefab)
* UILabel[] columns = GetChildren()
* columns[0].text = value; columns[1].text = value; columns[2].text = value;

Once the prefab is setup, I'll grant it's pretty easy to use and work with.  But if you want something quick & dirty, the "tabs" approach is better.

sathyaraj

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: UILabel
« Reply #34 on: February 24, 2014, 04:01:32 AM »
Is it possible to change font size inside UILabel. Something like this instead of using two separate labels. "Different font size" If you see text "font", its small in size compared to others.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel
« Reply #35 on: February 24, 2014, 05:07:30 PM »
You can use the [sub] tag to shrink the text, but you can't reference different fonts mid-sentence.

Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
Re: UILabel
« Reply #36 on: February 26, 2014, 05:38:47 AM »
Hi ArenMook,

In the older versions of NGUI it was possible to call:
UILabel.password = true

To set the UILabel to show a password field instead of just plain text. Is this still possible in the latest version of NGUI? I can't seem to find how.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel
« Reply #37 on: February 26, 2014, 03:52:22 PM »
Yes, you set it on the UIInput instead.

Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
Re: UILabel
« Reply #38 on: February 27, 2014, 04:21:22 AM »
Yes, you set it on the UIInput instead.

Thx for your reply.

I don't need an input field there, I have a ATM machine (sort of) and the numbers are added through buttons not with an input text field. I've attached the InputField script to my label and set it to password. But when i'm adding numbers by pressing on the buttons they aren't **** but just 1234.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel
« Reply #39 on: February 27, 2014, 06:49:12 PM »
If you are setting your label's text directly, then just replace what you're setting with stars.

angrypenguin

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UILabel
« Reply #40 on: March 05, 2014, 11:58:48 PM »
Overflow handling lets you determine what happens when the label's text exceeds the allowed space.
Under what conditions? I've got a bunch of widgets here which seem to partially apply the setting when I select "Resize Height" but then snap back to ShrinkContent.

Edit: Righto, it was having the anchor set to anything other than "None". While this makes sense from a nuts and bolts perspective it's a pretty counter-intuitive workflow, and my experience with the new anchor system thus far is that this isn't the only place where it has that effect. Another example is moving a parent object who's children have anchors on them. In each case I'd expect the anchor to be updated. After all, why would I want something to resize height and expect it to honor a specified height at the same time? Or why would I want to move a parent object and not have its children come for the ride?
« Last Edit: March 06, 2014, 12:15:40 AM by angrypenguin »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel
« Reply #41 on: March 06, 2014, 12:18:09 PM »
Anchors do get updated as long as the children are anchored to the parent you're moving, not to some external source.

bearworks

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: UILabel
« Reply #42 on: March 10, 2014, 07:09:22 AM »
Can we give some offset to underline ,like this : [u=0.1]...[/u] ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel
« Reply #43 on: March 10, 2014, 09:19:59 PM »
The underline is always based where the "_" character is located.

blitzer

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 52
    • View Profile
Re: UILabel
« Reply #44 on: March 10, 2014, 09:22:50 PM »
I was wondering if there was any way to have "multiple" text aligments in 1 UILabel (I'm guessing no). I know that I would accomplish this by using multiple labels, I just thought it would be nice if I could code this in 1 label.

Ex.
Blah blah lots of text explaining something, here is your score:(aligned left, clamp content)
Score (aligned center)
More text about something else (aligned left, clamp content)