Petition-to-the-Gods-V3/Assets/Scripts/Client/ClientFinalSceneController.cs
2025-11-18 14:54:11 +08:00

62 lines
1.4 KiB
C#

using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.Video;
public class ClientFinalSceneController : MonoBehaviour
{
public static ClientFinalSceneController Instance;
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(1080, 1920, 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("ClientHomeScene");
}
}