1. 程式人生 > >判斷當前音效是否播放完畢

判斷當前音效是否播放完畢

public class ZhuaZuoYePiao : MonoBehaviour {


    public bool IsOnce = true;
    public GameObject daimaoren;
    public GameObject zuoyepiao;




    void OnTriggerEnter(Collider other)
    {                       //抓取物體,把被抓物體歸為子物體
        if (other.tag == "zuoyepiao")
        {
            other.transform.parent = this.gameObject.transform;         //把作業票作為手柄的子物體
            other.transform.localPosition = Vector3.zero;               //把作業票的自身位置歸0,0,0;


            //解除物體之間的父子關係
            // other.gameObject.transform.parent.


            SoundController._instance.SetAudio(AudioClipType.duzuoyepiao);      //播放作業票內容
        }
        
    }
    
    void Update()
    {
        if (SoundController._instance.audioSource.clip == SoundController._instance.audioClips[(int)AudioClipType.duzuoyepiao])     //判斷當前播放的是不是作業票內容
        {
            if (!SoundController._instance.audioSource.isPlaying)                                   //判斷作業票內容是否播放完畢
            {
                Debug.Log("帶帽人高亮顯示");
                Destroy(zuoyepiao);
            }
        }


    }


}