using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
public class testVedio : MonoBehaviour
{
public GameObject go;
public bool ison1 = false;
// Start is called before the first frame update
void Start()
{
Invoke("Setison",3);
}
void Setison() {
ison1 = true;
}
// Update is called once per frame
void Update()
{
if (ison1) {
if (GetComponent<VideoPlayer>().isPlaying)
{
// Debug.Log("frame"+ (ulong)GetComponent<VideoPlayer>().frame);
if ((ulong)GetComponent<VideoPlayer>().frame >= GetComponent<VideoPlayer>().frameCount-1)
{
Debug.Log("sssss");
// GetComponent<VideoPlayer>().Pause();
go.gameObject.SetActive(false);
ison1 = false;
}
}
}
}
}
Unity的VideoPlayer控制播放完毕
最新推荐文章于 2026-08-10 10:40:01 发布
该博客主要介绍了在Unity中实现视频播放的场景,通过`testVedio`类展示了如何在游戏对象上控制视频的播放状态。在`Start`方法中调用`Setison`方法延迟启动视频播放。在`Update`方法中,当视频达到最后一帧时,关闭游戏对象并重置状态。博客着重于Unity中的视频播放和帧操作控制。

5982

被折叠的 条评论
为什么被折叠?



