LaboratoryProtection/Assets/UnityTest/ZXL/Scripts/UI/TimeReversalUI.cs

54 lines
1.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using Sirenix.OdinInspector;
using UnityEngine;
using UnityEngine.Video;
namespace UnityTest.ZXL
{
public class TimeReversalUI : UI
{
[SerializeField] private VideoPlayer _videoPlayer;
private Action _action;
public override void OnInit()
{
base.OnInit();
_videoPlayer = GetComponentInChildren<VideoPlayer>();
_videoPlayer.started += Started;
_videoPlayer.loopPointReached += End;
}
private void OnDestroy()
{
_videoPlayer.started -= Started;
_videoPlayer.loopPointReached -= End;
}
private void Started( VideoPlayer vp)
{
Debug.Log("播放开始");
// TODO: 关闭所有UI待播放结束后开启被关闭的UI
// UIManager.Instance().HideAllUI();
// UIManager.Instance().ShowUI(UIType.TimeReversal);
}
private void End(VideoPlayer source)
{
Debug.Log("播放结束");
_action?.Invoke();
}
public void SetAction(Action action)
{
_action = action;
}
#if UNITY_EDITOR
[Button]
void Test()
{
_videoPlayer.Play();
}
#endif
}
}