Files
BabyVideo/Assets/Scripts/UI/PlayerPanel.cs
2026-02-09 20:10:14 +08:00

60 lines
1.4 KiB
C#

// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
using FairyGUI;
using UnityEngine;
using NBC;
using UIPanel = NBC.UIPanel;
namespace NBF
{
public partial class PlayerPanel : UIPanel
{
private int TryGetTime = 5;
protected override void OnShowed()
{
this.AutoAddClick(OnClick);
TryGetTime = 5;
Progress.max = 1;
GetVideoData();
stageCtrl.selectedIndex = 0;
}
private void GetVideoData()
{
Game.Instance.GetList(OnGetList);
}
private void OnGetList()
{
if (Game.Instance.Videos.Count > 0)
{
stageCtrl.selectedIndex = 1;
}
else
{
Notices.Show($"没有视频数据!{TryGetTime}秒后重试");
Timer.Once(TryGetTime, this, GetVideoData);
TryGetTime *= 2;
}
}
protected override void OnUpdate()
{
base.OnUpdate();
Progress.value = VideoManager.Instance.PlayProgress;
}
private void OnClick(GComponent btn)
{
if (btn == BtnNext)
{
VideoManager.Instance.Next();
}
else if (btn == BtnPrev)
{
VideoManager.Instance.Previous();
}
}
}
}