using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// ¾È»¤³µ /// public class Ambulance : SkillCar { /// /// ×ó¾¯µÑ /// public Transform leftPoliceWhistle; /// /// ÓÒ¾¯µÑ /// public Transform rightPoliceWhistle; /// /// ¾¯µÑЭ³Ì /// private Coroutine policeWhistleCoroutine; private void OnDisable() { StopPoliceWhistle(); } /// /// ¾¯µÑ /// public void PoliceWhistle() { policeWhistleCoroutine= StartCoroutine(IE_PoliceWhistle()); } /// /// ¾¯µÑЭ³Ì /// private IEnumerator IE_PoliceWhistle() { while (true) { leftPoliceWhistle.gameObject.SetActive(true); rightPoliceWhistle.gameObject.SetActive(false); yield return new WaitForSeconds(0.1f); rightPoliceWhistle.gameObject.SetActive(true); leftPoliceWhistle.gameObject.SetActive(false); yield return new WaitForSeconds(0.1f); } } /// /// ÔÝÍ£ /// public void StopPoliceWhistle() { if(policeWhistleCoroutine!=null) { leftPoliceWhistle.gameObject.SetActive(false); rightPoliceWhistle.gameObject.SetActive(false); StopCoroutine(policeWhistleCoroutine); policeWhistleCoroutine = null; } } }