Health/Assets/Scripts/UI/ActionGuideVideoPanel.cs

60 lines
1.2 KiB
C#
Raw Normal View History

using SRF;
2023-11-07 13:55:35 +00:00
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Video;
[RequireComponent(typeof(VideoPlayer))]
public class ActionGuideVideoPanel : UIPopupBase
{
public VideoPlayer _video;
private YogaData _data;
2023-11-07 13:55:35 +00:00
private void Awake()
{
_video = GetComponent<VideoPlayer>();
}
public override void Init(object[] pageData)
{
base.Init(pageData);
_data = pageData[0] as YogaData;
2023-11-07 13:55:35 +00:00
2023-11-14 10:52:43 +00:00
//动作引导界面
Debug.Log(_data.VideoPath);
var video = Resources.Load<VideoClip>(_data.VideoPath);
if (_video == null)
{
_video = gameObject.GetComponentOrAdd<VideoPlayer>();
}
_video.clip = video;
2023-11-10 07:17:23 +00:00
_video.isLooping = true;
_video.playOnAwake = false;
2023-11-07 13:55:35 +00:00
_video.Prepare();
}
public void OnOKClicked()
{
PageDispose();
UIManager.Instance.ShowPanel<GuideUI>(_data);
2023-11-07 13:55:35 +00:00
}
private void PageDispose()
{
_video.Stop();
UIManager.Instance.CloseCurrent();
}
public void OnReturnClicked()
{
PageDispose();
LoadingManager.Instance.Load("Boot");
}
public override void OnEnter()
{
base.OnEnter();
_video.Play();
}
}