This commit is contained in:
2025-10-14 14:29:08 +08:00
parent b085bb31d0
commit 4933c99c07
4 changed files with 69 additions and 17 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using DG.Tweening; using DG.Tweening;
using UnityEngine; using UnityEngine;
@@ -6,6 +7,7 @@ using UnityEngine.UI;
#if HotUpdate #if HotUpdate
using YooAsset; using YooAsset;
#endif #endif
namespace Stary.Evo.UIFarme namespace Stary.Evo.UIFarme
{ {
public interface IBasePanel : IController public interface IBasePanel : IController
@@ -14,6 +16,7 @@ namespace Stary.Evo.UIFarme
/// UI信息 /// UI信息
/// </summary> /// </summary>
string UIName { get; set; } string UIName { get; set; }
/// <summary> /// <summary>
/// 绑定这个面板的实例 /// 绑定这个面板的实例
/// </summary> /// </summary>
@@ -28,7 +31,7 @@ namespace Stary.Evo.UIFarme
/// <summary> /// <summary>
/// 虚方法UI进入时执行的操作只会执行一次 /// 虚方法UI进入时执行的操作只会执行一次
/// </summary> /// </summary>
void OnEnter(); void OnEnter(Action complete = null);
/// <summary> /// <summary>
/// 虚方法UI暂停时执行的操作只会执行一次 /// 虚方法UI暂停时执行的操作只会执行一次
@@ -74,6 +77,8 @@ namespace Stary.Evo.UIFarme
/// </summary> /// </summary>
public string UIName { get; set; } public string UIName { get; set; }
public abstract UITweenType TweenType { get; }
/// <summary> /// <summary>
/// 面板管理器 /// 面板管理器
/// </summary> /// </summary>
@@ -118,11 +123,27 @@ namespace Stary.Evo.UIFarme
} }
public virtual void OnEnter() public virtual void OnEnter(Action complete = null)
{ {
activePanel.SetActive(true); activePanel.SetActive(true);
canvasGroup.blocksRaycasts = 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() public virtual void OnPause()
@@ -169,15 +190,15 @@ namespace Stary.Evo.UIFarme
} }
else else
{ {
var package = YooAssets.TryGetPackage(packageName); var package = YooAssets.TryGetPackage(packageName);
if (package == null) if (package == null)
{ {
handle = YooAssets.LoadAssetAsync<GameObject>(panelName); handle = YooAssets.LoadAssetAsync<GameObject>(panelName);
} }
else else
{ {
handle = package.LoadAssetAsync<GameObject>(panelName); handle = package.LoadAssetAsync<GameObject>(panelName);
} }
} }
await handle.Task; await handle.Task;
@@ -192,7 +213,7 @@ namespace Stary.Evo.UIFarme
activePanel.name = this.GetType().Name; activePanel.name = this.GetType().Name;
if (!activePanel.GetComponentInChildren<Canvas>() && !activePanel.GetComponentInParent<Canvas>()) if (!activePanel.GetComponentInChildren<Canvas>() && !activePanel.GetComponentInParent<Canvas>())
{ {
Debug.LogError($"UnityEvo:panelParent上不存在Canvas组件,{panelName}无法正常运行,进程已中断,请检查!!!!!"); Debug.LogError($"UnityEvo:panelParent上不存在Canvas组件,{panelName}无法正常运行,进程已中断,请检查!!!!!");
return null; return null;
@@ -236,5 +257,28 @@ namespace Stary.Evo.UIFarme
{ {
return PanelSystem.GetArchitecture(); return PanelSystem.GetArchitecture();
} }
public enum UITweenType
{
/// <summary>
/// 无动画
/// </summary>
None,
/// <summary>
/// 淡入淡出
/// </summary>
Fade,
/// <summary>
/// 循环播放
/// </summary>
Loop,
/// <summary>
/// 往返播放
/// </summary>
Yoyo,
}
} }
} }

View File

@@ -22,6 +22,7 @@ namespace Stary.Evo.UIFarme
/// </summary> /// </summary>
void PopQueue<T>(string panelName=null) where T : IBasePanel, new(); void PopQueue<T>(string panelName=null) where T : IBasePanel, new();
void PopQueue<T>(T t, string panelName=null) where T : IBasePanel, new();
/// <summary> /// <summary>
/// 执行面板的出栈操作此操作会执行面板的OnExit方法 /// 执行面板的出栈操作此操作会执行面板的OnExit方法
/// </summary> /// </summary>
@@ -203,6 +204,11 @@ namespace Stary.Evo.UIFarme
} }
} }
public void PopQueue<T>(T t, string panelName = null) where T : IBasePanel, new()
{
PopQueue<T>(panelName);
}
public void PopStack() public void PopStack()
{ {
if (stackPanel.Count > 0) if (stackPanel.Count > 0)

View File

@@ -31,6 +31,8 @@ public class VideoPanel : BasePanel
} }
public override UITweenType TweenType => UITweenType.Fade;
public override void Initialize(GameObject panelGo) public override void Initialize(GameObject panelGo)
{ {
base.Initialize(panelGo); base.Initialize(panelGo);
@@ -43,9 +45,9 @@ public class VideoPanel : BasePanel
_animator = area.GetComponentInChildren<Animator>(); _animator = area.GetComponentInChildren<Animator>();
} }
public override void OnEnter() public override void OnEnter(Action complete = null)
{ {
base.OnEnter(); base.OnEnter(complete);
this.RegisterEvent<ModeType, VideoInfo>(ModeType.VideoStart, OnStartMove); this.RegisterEvent<ModeType, VideoInfo>(ModeType.VideoStart, OnStartMove);
this.RegisterEvent<ModeType>(ModeType.VideoEnd, OnStopMove); this.RegisterEvent<ModeType>(ModeType.VideoEnd, OnStopMove);

View File

@@ -1,6 +1,6 @@
{ {
"name": "com.staryevo.tools", "name": "com.staryevo.tools",
"version": "1.1.2", "version": "1.1.3",
"displayName": "00.StaryEvo.Tools", "displayName": "00.StaryEvo.Tools",
"description": "This is an Framework package(后台服务器版本端口9527)", "description": "This is an Framework package(后台服务器版本端口9527)",
"unity": "2021.3", "unity": "2021.3",