// Update is called once per frame void Update() { elapsedTime += Time.deltaTime; if (elapsedTime < maxTime) { //end stage Target[] stageTargets = gameObject.GetComponentsInChildren <Target>(true); foreach (Target target in stageTargets) { if (elapsedTime > target.generateTime) { target.Activation(true); } } timeBar.GetComponent <RectTransform>().sizeDelta = new Vector2(550 * (elapsedTime / maxTime), 3); } else { globalControl.endStage(); } }