hi i'm having a little trouble in my unity game and i'm hoping to have a little help here. i have some clickables GO in my scene, i need to show a panel with a Slider as children whenever a GO is clicked, the slider when showed should increase it's value progressivly until it's filled. My problem is that the Slider increases it's value one time (not until its filled) as i clicked over the GO one time, what i want is that the Slider should increase it's value until it's filled everytime i clicks over a GO i'm using this code but it's not working Code (CSharp): void OnMouseDown(){ GameObject.Find ("CanvasAliments").GetComponent<CanvasGroup> ().alpha = 1; Slider niveau = GameObject.Find ("CanvasAliments").transform.FindChild ("Panel").transform.FindChild ("Slider").GetComponent<Slider> (); niveau.value += Time.deltaTime; if (niveau.value == 1) { Debug.Log ("done"); } }
Put a breakpoint on line 4 and see what the niveau.value is after each click. Keep in mind Time.deltaTime is usually quite small, 1/50th of a second or so, so it will take a lot of clicks to get the value up to 1.