using System.Collections; using System.Collections.Generic; using UnityEngine; using SC.XR.Unity; public class Saomiao : MonoBehaviour { public SCSlider3D Slider; public BoxCollider Collider; public BoxCollider TrackCollider; public GameObject JiRou; public void OnClick() { StartCoroutine(PlayAni()); JiRou.SetActive(true); } IEnumerator PlayAni() { Collider.enabled = false; TrackCollider.enabled = false; float i = 0; bool isrun = true; while (true) { yield return new WaitForSeconds(0.005f); if (isrun) { i += 0.002f; if (i >= 1) { i = 1; isrun = false; } Slider.value = i; } else { i -= 0.002f; if (i <= 0) { Slider.value = 0; Collider.enabled = true; TrackCollider.enabled = true; yield break; } Slider.value = i; } } } }