78 lines
2.5 KiB
C#
78 lines
2.5 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TEngine;
|
|
using UnityEngine.Video;
|
|
using GameConfig;
|
|
using Cysharp.Threading.Tasks;
|
|
using System.Collections.Generic;
|
|
using YooAsset;
|
|
using GameConfig.giftConfig;
|
|
|
|
namespace GameLogic
|
|
{
|
|
[Window(UILayer.UI)]
|
|
class UIVipLiWuHongItem : UIWindow
|
|
{
|
|
#region 脚本工具生成的代码
|
|
private RawImage m_rimg_ViewTexture;
|
|
private VideoPlayer m_VideoPlayer;
|
|
|
|
protected override void ScriptGenerator()
|
|
{
|
|
m_rimg_ViewTexture = FindChildComponent<RawImage>("m_rimg_ViewTexture");
|
|
m_VideoPlayer = FindChildComponent<VideoPlayer>("m_video_Video");
|
|
}
|
|
#endregion
|
|
|
|
#region 事件
|
|
#endregion
|
|
|
|
protected override void OnCreate()
|
|
{
|
|
base.OnCreate();
|
|
GiftItemData giftItemData = UserData as GiftItemData;
|
|
|
|
if (giftItemData.giftId == 0)
|
|
{
|
|
Log.Error("ID == 0");
|
|
GameModule.UI.CloseUI<UIVipLiWuHongItem>();
|
|
return;
|
|
}
|
|
// 根据礼物Id,加载对应的视频名称
|
|
// GiftConfig giftConfig = ConfigSystem.Instance.Tables.TbGift.Get(giftItemData.giftId);
|
|
// string videoName = giftItemData.m_TeamEnum == TeamUnitEnum.Left? giftConfig.LeftVIdeoName:giftConfig.RightVideoName;
|
|
string videoName = "Gift0" + (giftItemData.giftId);
|
|
m_VideoPlayer.loopPointReached += HiddenVideoPlay;
|
|
|
|
var videoClip = GameModule.Resource.LoadAsset<VideoClip>(videoName);
|
|
|
|
//string audioName = "礼物" + (giftItemData.giftId - 1);
|
|
//// 播放音效
|
|
//GameModule.Audio.Play(TEngine.AudioType.UISound, audioName, false, 0.5f, true);
|
|
|
|
m_VideoPlayer.clip = videoClip;
|
|
m_VideoPlayer.Play();
|
|
|
|
HideVideo();
|
|
}
|
|
protected override void OnUpdate()
|
|
{
|
|
base.OnUpdate();
|
|
}
|
|
private async void HideVideo()
|
|
{
|
|
await UniTask.Delay(2000);
|
|
m_VideoPlayer.targetTexture.DiscardContents();
|
|
GameModule.UI.CloseUI<UIVipLiWuHongItem>();
|
|
//GameModule.UI.CloseUI<UIVipItem_Old>();
|
|
//GameModule.UI.ShowUI<UIVipItem>(UserDatas);
|
|
}
|
|
|
|
private void HiddenVideoPlay(VideoPlayer player)
|
|
{
|
|
// m_VideoPlayer.targetTexture.DiscardContents();
|
|
// GameModule.UI.CloseUI<UIVipLiWuHongItem>();
|
|
}
|
|
}
|
|
}
|