[SerializeField] VideoClip[] videoClips;
VideoPlayer videoPlayer;
int currentIdx;
int len;
bool isPlay = false;
float timer;
void Start()
{
currentIdx = 0;
videoPlayer = GetComponent<VideoPlayer>();
SetVideoClip(currentIdx);
videoPlayer.started += delegate { Ready(); };
timer = 0;
len = videoClips.Length;
}
void Ready()
{
isPlay = true;
}
private void Update()
{
if (!isPlay)return;
if (!videoPlayer.isPlaying)
{
timer+=Time.deltaTime;
if (timer > 2f)
{
isPlay = false;
currentIdx++;
currentIdx %= len;
SetVideoClip(currentIdx);
timer = 0;
}
}
}
void SetVideoClip(int idx)
{
Debug.Log(idx);
videoPlayer.clip = videoClips[idx];
videoPlayer.Play();
}
unity 播放完视频,暂停2秒播放下一个
于 2023-03-22 15:49:26 首次发布