65 lines
1.5 KiB
C#
65 lines
1.5 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.Video;
|
|
using UnityEngine.SceneManagement;
|
|
using System.Collections;
|
|
using System.Net.Sockets;
|
|
|
|
public class ClientWorkMessageResultYesSceneController : MonoBehaviour
|
|
{
|
|
public static ClientWorkMessageResultYesSceneController Instance;
|
|
|
|
[Header("影片播放")]
|
|
public VideoPlayer videoPlayer;
|
|
public RawImage videoDisplay;
|
|
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
SetupVideoPlayer();
|
|
|
|
// 開始播放影片
|
|
if (videoPlayer != null)
|
|
{
|
|
videoPlayer.Play();
|
|
Debug.Log("開始播放影片");
|
|
}
|
|
}
|
|
|
|
void SetupVideoPlayer()
|
|
{
|
|
if (videoPlayer != null)
|
|
{
|
|
// 設置影片結束事件
|
|
videoPlayer.loopPointReached += OnVideoFinished;
|
|
|
|
// 設置影片顯示
|
|
if (videoDisplay != null)
|
|
{
|
|
videoPlayer.targetTexture = null;
|
|
videoPlayer.renderMode = VideoRenderMode.RenderTexture;
|
|
RenderTexture rt = new RenderTexture(1920, 1080, 24);
|
|
videoPlayer.targetTexture = rt;
|
|
videoDisplay.texture = rt;
|
|
}
|
|
}
|
|
}
|
|
|
|
void OnVideoFinished(VideoPlayer vp)
|
|
{
|
|
Debug.Log("影片播放完成,準備跳轉");
|
|
StartCoroutine(LoadNextScene());
|
|
}
|
|
|
|
public IEnumerator LoadNextScene()
|
|
{
|
|
yield return new WaitForSeconds(0f);
|
|
SceneManager.LoadScene("ClientWorkMessageFinishScene");
|
|
|
|
}
|
|
|
|
} |