using UnityEngine; using UnityEngine.UI; using UnityEngine.Video; using UnityEngine.SceneManagement; using System.Collections; public class ServerIntroSceneController : MonoBehaviour { public static ServerIntroSceneController Instance; [Header("影片播放")] public VideoPlayer videoPlayer; public RawImage videoDisplay; private void Awake() { Instance = this; } void Start() { SetupVideoPlayer(); // 開始播放影片 if (videoPlayer != null) { videoPlayer.Play(); } } 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("ServerWorkScene"); } }