Author Topic: Addons to UILabel  (Read 2029 times)

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Addons to UILabel
« on: December 27, 2013, 05:42:15 AM »
Hello !

Currently on a slider, we can have a OnValueChange. If we drop a UILabel on this, we have some methods at disposal, such as UILabel.SetCurrentPercent.
It would be nice to have so more options here, such as SetCurrentValue and SetCurrentStepValue.

I added them on a different script that I attach to my label, but I think it would be nice to have them by default no ?

  1. public void setCurrentStepValue()
  2. {
  3.         if (UIProgressBar.current != null)
  4.         {
  5.                 m_label.text = (m_startingValue + Mathf.Round(UIProgressBar.current.value * (UIProgressBar.current.numberOfSteps - 1))).ToString();
  6.         }
  7. }
  8.  

  1. public void setCurrentValue()
  2. {
  3.         if (UIProgressBar.current != null)
  4.         {
  5.                 m_label.text = UIProgressBar.current.value.ToString("f1");
  6.         }
  7. }
  8.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Addons to UILabel
« Reply #1 on: December 27, 2013, 04:11:57 PM »
I've added the value one to the label, but I don't see much of a usecase for the step one...

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: Addons to UILabel
« Reply #2 on: December 28, 2013, 12:25:21 PM »
Cool !

Imagine you have a UI where you want to create between 1-10 monsters. You just set the slider with 10 steps and display on the thumb the current step :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Addons to UILabel
« Reply #3 on: December 28, 2013, 04:04:17 PM »
Yeah, that's a pretty custom functionality. You should keep it local to your own script.

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: Addons to UILabel
« Reply #4 on: December 29, 2013, 03:13:36 PM »
I disagree but OK ;)