- Home /
Make object appear using SetActiveRecursively with a slider moving overtime
Hi
Im trying to make objects appear overtime using a slider that activates on button press. So by pressing the button the Slider moves from float values 0.0 - 20.0. So far I have tried Slider = Time.time which works under the Update function but now the GameObjects will not appear when the slider equals the value they are supposed to SetActiveRecursively under i.e. the slider moves automatically but the objects are still inactive along the slider, they are inactive on start so are meant to appear after slider has reached x value.
JavaScript Code below:
var Stage0 : GameObject;
var Slider : float = 0.0;
var minSlider : float = 0.0; var maxSlider : float = 20.0;
//CREATE HORIZONTAL SLIDER function OnGUI () {
Slider = GUI.HorizontalSlider (Rect (20, 100, 1000, 50), Slider, 0.0, 20.0);
if (GUI.Button(Rect(20, 20, 100, 50), "APPEAR" )) {
//CODE THAT CAN AUTOMATE SLIDER TO MOVE FROM LEFT TO RIGHT ON BUTTON PRESS (OTHER THAN UPDATE - Time.time
}
//SLIDER FUNCTIONALITY
if (Slider <= 0.0) { Stage0.SetActiveRecursively(!Stage0.active); Stage0.GetComponent.().Play(); }
if (Slider <= 1.0) { Stage1.SetActiveRecursively(!Stage1.active); Stage1.GetComponent.().Play(); }
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612131341im_/https://answers.unity.com/themes/thub/images/avi.jpg)