Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: nah0y on December 27, 2013, 05:42:15 AM

Title: Addons to UILabel
Post by: nah0y 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.  
Title: Re: Addons to UILabel
Post by: ArenMook 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...
Title: Re: Addons to UILabel
Post by: nah0y 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 :)
Title: Re: Addons to UILabel
Post by: ArenMook on December 28, 2013, 04:04:17 PM
Yeah, that's a pretty custom functionality. You should keep it local to your own script.
Title: Re: Addons to UILabel
Post by: nah0y on December 29, 2013, 03:13:36 PM
I disagree but OK ;)