diff --git a/Assets/00.StaryEvoTools/Runtime/Tools/PanelSystem/Base/BasePanel.cs b/Assets/00.StaryEvoTools/Runtime/Tools/PanelSystem/Base/BasePanel.cs index 3f22a7f..f8a0ff0 100644 --- a/Assets/00.StaryEvoTools/Runtime/Tools/PanelSystem/Base/BasePanel.cs +++ b/Assets/00.StaryEvoTools/Runtime/Tools/PanelSystem/Base/BasePanel.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Threading.Tasks; using DG.Tweening; using UnityEngine; @@ -6,6 +7,7 @@ using UnityEngine.UI; #if HotUpdate using YooAsset; #endif + namespace Stary.Evo.UIFarme { public interface IBasePanel : IController @@ -14,6 +16,7 @@ namespace Stary.Evo.UIFarme /// UI信息 /// string UIName { get; set; } + /// /// 绑定这个面板的实例 /// @@ -28,7 +31,7 @@ namespace Stary.Evo.UIFarme /// /// 虚方法,UI进入时执行的操作,只会执行一次 /// - void OnEnter(); + void OnEnter(Action complete = null); /// /// 虚方法,UI暂停时执行的操作,只会执行一次 @@ -74,6 +77,8 @@ namespace Stary.Evo.UIFarme /// public string UIName { get; set; } + public abstract UITweenType TweenType { get; } + /// /// 面板管理器 /// @@ -118,11 +123,27 @@ namespace Stary.Evo.UIFarme } - public virtual void OnEnter() + public virtual void OnEnter(Action complete = null) { activePanel.SetActive(true); canvasGroup.blocksRaycasts = true; - canvasGroup.DOFade(1f, 1f); + if (TweenType == UITweenType.Fade) + { + canvasGroup.alpha = 1f; + } + + if (TweenType == UITweenType.Fade) + { + canvasGroup.DOFade(1f, 2f).OnComplete(() => { complete?.Invoke(); }); + } + else if (TweenType == UITweenType.Yoyo) + { + canvasGroup.DOFade(1, 2f).SetLoops(2, LoopType.Yoyo).OnComplete(() => { complete?.Invoke(); }); + } + else + { + canvasGroup.DOFade(1, 2f).SetLoops(-1).OnComplete(() => { complete?.Invoke(); }); + } } public virtual void OnPause() @@ -169,15 +190,15 @@ namespace Stary.Evo.UIFarme } else { - var package = YooAssets.TryGetPackage(packageName); - if (package == null) - { - handle = YooAssets.LoadAssetAsync(panelName); - } - else - { - handle = package.LoadAssetAsync(panelName); - } + var package = YooAssets.TryGetPackage(packageName); + if (package == null) + { + handle = YooAssets.LoadAssetAsync(panelName); + } + else + { + handle = package.LoadAssetAsync(panelName); + } } await handle.Task; @@ -192,7 +213,7 @@ namespace Stary.Evo.UIFarme activePanel.name = this.GetType().Name; - if (!activePanel.GetComponentInChildren() && !activePanel.GetComponentInParent()) + if (!activePanel.GetComponentInChildren() && !activePanel.GetComponentInParent()) { Debug.LogError($"UnityEvo:panelParent上不存在Canvas组件,{panelName}无法正常运行,进程已中断,请检查!!!!!"); return null; @@ -236,5 +257,28 @@ namespace Stary.Evo.UIFarme { return PanelSystem.GetArchitecture(); } + + public enum UITweenType + { + /// + /// 无动画 + /// + None, + + /// + /// 淡入淡出 + /// + Fade, + + /// + /// 循环播放 + /// + Loop, + + /// + /// 往返播放 + /// + Yoyo, + } } } \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tools/PanelSystem/Manager/PanelSystem.cs b/Assets/00.StaryEvoTools/Runtime/Tools/PanelSystem/Manager/PanelSystem.cs index 0f41ac0..af0d02e 100644 --- a/Assets/00.StaryEvoTools/Runtime/Tools/PanelSystem/Manager/PanelSystem.cs +++ b/Assets/00.StaryEvoTools/Runtime/Tools/PanelSystem/Manager/PanelSystem.cs @@ -22,6 +22,7 @@ namespace Stary.Evo.UIFarme /// void PopQueue(string panelName=null) where T : IBasePanel, new(); + void PopQueue(T t, string panelName=null) where T : IBasePanel, new(); /// /// 执行面板的出栈操作,此操作会执行面板的OnExit方法 /// @@ -203,6 +204,11 @@ namespace Stary.Evo.UIFarme } } + public void PopQueue(T t, string panelName = null) where T : IBasePanel, new() + { + PopQueue(panelName); + } + public void PopStack() { if (stackPanel.Count > 0) diff --git a/Assets/00.StaryEvoTools/Runtime/VideoSystemPanel/VideoPanel.cs b/Assets/00.StaryEvoTools/Runtime/VideoSystemPanel/VideoPanel.cs index b6fcf38..35ceb45 100644 --- a/Assets/00.StaryEvoTools/Runtime/VideoSystemPanel/VideoPanel.cs +++ b/Assets/00.StaryEvoTools/Runtime/VideoSystemPanel/VideoPanel.cs @@ -31,6 +31,8 @@ public class VideoPanel : BasePanel } + public override UITweenType TweenType => UITweenType.Fade; + public override void Initialize(GameObject panelGo) { base.Initialize(panelGo); @@ -43,9 +45,9 @@ public class VideoPanel : BasePanel _animator = area.GetComponentInChildren(); } - public override void OnEnter() + public override void OnEnter(Action complete = null) { - base.OnEnter(); + base.OnEnter(complete); this.RegisterEvent(ModeType.VideoStart, OnStartMove); this.RegisterEvent(ModeType.VideoEnd, OnStopMove); diff --git a/Assets/00.StaryEvoTools/package.json b/Assets/00.StaryEvoTools/package.json index 821352e..cad4710 100644 --- a/Assets/00.StaryEvoTools/package.json +++ b/Assets/00.StaryEvoTools/package.json @@ -1,6 +1,6 @@ { "name": "com.staryevo.tools", - "version": "1.1.2", + "version": "1.1.3", "displayName": "00.StaryEvo.Tools", "description": "This is an Framework package(后台服务器版本,端口9527)", "unity": "2021.3",