Unity 音乐或者视频播放完毕之后执行方法

音乐播放完毕后,执行某个方法

    private IEnumerator AudioCallBack(AudioSource AudioObject,Action action)
    {
        Debug.Log(AudioObject.isPlaying);
        while (AudioObject.isPlaying)
        {
            yield return new WaitForSecondsRealtime(0.1f);//延迟零点一秒执行
        }
        action();
    }

视频同样的道理

    private IEnumerator VideoCallBack(VideoPlayer VideoObject, Action action)
    {
        Debug.Log(VideoObject.isPlaying);
        while (VideoObject.isPlaying)
        {
             yield return new WaitForFixedUpdate(); //跟FixedUpdate 一样根据固定帧 更新
        }
        action();
    }

猜你喜欢

转载自www.cnblogs.com/Aaron-Han/p/12177519.html