using UnityEngine; using UnityEngine.UI; using UnityEngine.Video; using YooAsset; using GFGGame.Launcher; using System.Collections; using System.Collections.Generic; namespace GFGGame { public class LuckyBoxVideoView : SingletonMonoBase { private const float VideoWidth = 1080f; private const float VideoHeight = 1920f; private GameObject _ui; private AssetHandle handle; private RawFileHandle videoHandle; private RawImage imgVideo; private Button BtnSkipVertical; private VideoPlayer videoPlayer; private AudioSource audioSource; private List _rewardList; public void Show(List _reward = null) { FairyGUI.GRoot.inst.touchable = false; string path = ResPathUtil.GetUUIPrefabPath("UILuckyBox"); // 异步加载UI预制体 var uiLoadOperation = YooAssets.LoadAssetAsync(path); uiLoadOperation.Completed += (op) => { if (op.Status == EOperationStatus.Succeed) { handle = op; _ui = handle.InstantiateSync(UGUIManager.Instance.desktop.transform); InitializeUIComponents(); LoadAndPlayVideo(); } else { Debug.LogError($"Failed to load UI prefab: {path}"); FairyGUI.GRoot.inst.touchable = true; // 恢复触摸 } }; _rewardList = _reward; } private void InitializeUIComponents() { imgVideo = _ui.transform.Find("ImgVideo").GetComponent(); Vector2 imgVideoSizeDelta = imgVideo.rectTransform.sizeDelta; imgVideoSizeDelta.y = Screen.height; imgVideoSizeDelta.x = (VideoWidth / VideoHeight) * imgVideoSizeDelta.y; imgVideo.rectTransform.sizeDelta = imgVideoSizeDelta; BtnSkipVertical = _ui.transform.Find("BtnSkipVertical").GetComponent