111
This commit is contained in:
@@ -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信息
|
||||
/// </summary>
|
||||
string UIName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 绑定这个面板的实例
|
||||
/// </summary>
|
||||
@@ -28,7 +31,7 @@ namespace Stary.Evo.UIFarme
|
||||
/// <summary>
|
||||
/// 虚方法,UI进入时执行的操作,只会执行一次
|
||||
/// </summary>
|
||||
void OnEnter();
|
||||
void OnEnter(Action complete = null);
|
||||
|
||||
/// <summary>
|
||||
/// 虚方法,UI暂停时执行的操作,只会执行一次
|
||||
@@ -74,6 +77,8 @@ namespace Stary.Evo.UIFarme
|
||||
/// </summary>
|
||||
public string UIName { get; set; }
|
||||
|
||||
public abstract UITweenType TweenType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 面板管理器
|
||||
/// </summary>
|
||||
@@ -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<GameObject>(panelName);
|
||||
}
|
||||
else
|
||||
{
|
||||
handle = package.LoadAssetAsync<GameObject>(panelName);
|
||||
}
|
||||
var package = YooAssets.TryGetPackage(packageName);
|
||||
if (package == null)
|
||||
{
|
||||
handle = YooAssets.LoadAssetAsync<GameObject>(panelName);
|
||||
}
|
||||
else
|
||||
{
|
||||
handle = package.LoadAssetAsync<GameObject>(panelName);
|
||||
}
|
||||
}
|
||||
|
||||
await handle.Task;
|
||||
@@ -192,7 +213,7 @@ namespace Stary.Evo.UIFarme
|
||||
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}无法正常运行,进程已中断,请检查!!!!!");
|
||||
return null;
|
||||
@@ -236,5 +257,28 @@ namespace Stary.Evo.UIFarme
|
||||
{
|
||||
return PanelSystem.GetArchitecture();
|
||||
}
|
||||
|
||||
public enum UITweenType
|
||||
{
|
||||
/// <summary>
|
||||
/// 无动画
|
||||
/// </summary>
|
||||
None,
|
||||
|
||||
/// <summary>
|
||||
/// 淡入淡出
|
||||
/// </summary>
|
||||
Fade,
|
||||
|
||||
/// <summary>
|
||||
/// 循环播放
|
||||
/// </summary>
|
||||
Loop,
|
||||
|
||||
/// <summary>
|
||||
/// 往返播放
|
||||
/// </summary>
|
||||
Yoyo,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user