Author Topic: Change UISlider value from 1f to 100 (int) ?  (Read 4743 times)

Mickman

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
Change UISlider value from 1f to 100 (int) ?
« on: April 18, 2013, 06:08:24 AM »
Hi,

  How to change ProgressBar Value to int 100  ?  ( current max = 1.0f )   

 
   

           

« Last Edit: April 29, 2013, 07:07:54 AM by Mickman »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Change Progress Bar value when pick up item [SOLVED]
« Reply #1 on: April 18, 2013, 05:49:53 PM »
float myValue = Mathf.Lerp(0, 100, slider.sliderValue);

Mickman

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
Re: Change Progress Bar value when pick up item [SOLVED]
« Reply #2 on: April 18, 2013, 05:58:00 PM »
thx so much for the snippet of magic

public float myValue = Mathf.Lerp(0, 100, slider.sliderValue); 

I'm not sure about  "  slider.sliderValue);  "

Is this supposed to be the name I gave to the script I created that changes the values ?

If so ...   I called it  SliderValueChange.cs

  1. public class SliderValueChange : MonoBehaviour {
  2.        
  3.         public UISlider progBar;
  4.         public Inventory sphereItem;
  5.         public float curValue;
  6.                        
  7.         void Update () {
  8.                 OnSliderChange();
  9.         }
  10.        
  11.         void OnSliderChange(){
  12.        
  13.         progBar.sliderValue = curValue;
  14.         curValue = Inventory.score;
  15.         }
  16. }
  17.  
  18.  
  19.  

not sure where to fit the given code...   ??
 
« Last Edit: April 29, 2013, 07:08:30 AM by Mickman »