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

时间:2020-01-10 19:25:42   收藏:0   阅读:970

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

    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();
    }

原文:https://www.cnblogs.com/Aaron-Han/p/12177519.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!