初始化
This commit is contained in:
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Code.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Code.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2be05114d96a43e4ad0b490d9afa57ee
|
||||
timeCreated: 1689323021
|
||||
243
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Code/UIBase.cs
vendored
Normal file
243
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Code/UIBase.cs
vendored
Normal file
@@ -0,0 +1,243 @@
|
||||
using System;
|
||||
using Sirenix.OdinInspector;
|
||||
using YIUIBind;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// UI基类
|
||||
/// </summary>
|
||||
[HideLabel]
|
||||
[HideReferenceObjectPicker]
|
||||
public abstract class UIBase
|
||||
{
|
||||
#region 所有table表禁止public 不允许任何外界获取
|
||||
|
||||
internal UIBindCDETable m_CDETable;
|
||||
protected UIBindCDETable CDETable => m_CDETable;
|
||||
|
||||
internal UIBindComponentTable m_ComponentTable;
|
||||
protected UIBindComponentTable ComponentTable => m_ComponentTable;
|
||||
|
||||
internal UIBindDataTable m_DataTable;
|
||||
protected UIBindDataTable DataTable => m_DataTable;
|
||||
|
||||
internal UIBindEventTable m_EventTable;
|
||||
protected UIBindEventTable EventTable => m_EventTable;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 当前UI的预设对象
|
||||
/// </summary>
|
||||
[LabelText("UI对象")]
|
||||
public GameObject OwnerGameObject;
|
||||
|
||||
/// <summary>
|
||||
/// 当前UI的Tsf
|
||||
/// </summary>
|
||||
[HideInInspector]
|
||||
public RectTransform OwnerRectTransform;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化状态
|
||||
/// </summary>
|
||||
private bool m_UIBaseInit;
|
||||
|
||||
public bool UIBaseInit => m_UIBaseInit;
|
||||
|
||||
//用这个不用.单例而已
|
||||
protected PanelMgr m_PanelMgr;
|
||||
|
||||
/// <summary>
|
||||
/// UI的资源包名
|
||||
/// </summary>
|
||||
public string UIPkgName => m_UIBindVo.PkgName;
|
||||
|
||||
/// <summary>
|
||||
/// UI的资源名称
|
||||
/// </summary>
|
||||
public string UIResName => m_UIBindVo.ResName;
|
||||
|
||||
/// <summary>
|
||||
/// 绑定信息
|
||||
/// </summary>
|
||||
private UIBindVo m_UIBindVo;
|
||||
|
||||
internal UIBindVo UIBindVo => m_UIBindVo;
|
||||
|
||||
/// <summary>
|
||||
/// 当前显示状态 显示/隐藏
|
||||
/// 不要使用这个设置显影
|
||||
/// 应该使用控制器 或调用方法 SetActive();
|
||||
/// </summary>
|
||||
public bool ActiveSelf
|
||||
{
|
||||
get
|
||||
{
|
||||
if (OwnerGameObject == null) return false;
|
||||
return OwnerGameObject.activeSelf;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化UIBase 由PanelMgr创建对象后调用
|
||||
/// 外部禁止
|
||||
/// </summary>
|
||||
internal bool InitUIBase(UIBindVo uiBindVo, GameObject ownerGameObject)
|
||||
{
|
||||
if (ownerGameObject == null)
|
||||
{
|
||||
Debug.LogError($"null对象无法初始化");
|
||||
return false;
|
||||
}
|
||||
|
||||
OwnerGameObject = ownerGameObject;
|
||||
OwnerRectTransform = ownerGameObject.GetComponent<RectTransform>();
|
||||
m_CDETable = OwnerGameObject.GetComponent<UIBindCDETable>();
|
||||
if (CDETable == null)
|
||||
{
|
||||
Debug.LogError($"{OwnerGameObject.name} 没有UIBindCDETable组件 这是必须的");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_ComponentTable = CDETable.ComponentTable;
|
||||
m_DataTable = CDETable.DataTable;
|
||||
m_EventTable = CDETable.EventTable;
|
||||
|
||||
m_UIBaseInit = true;
|
||||
m_UIBindVo = uiBindVo;
|
||||
m_PanelMgr = PanelMgr.Inst;
|
||||
CDETable.BindUIBase(this);
|
||||
UIBaseInitialize();
|
||||
return true;
|
||||
}
|
||||
|
||||
#region 公共方法
|
||||
|
||||
/// <summary>
|
||||
/// 设置显隐
|
||||
/// </summary>
|
||||
public void SetActive(bool value)
|
||||
{
|
||||
if (OwnerGameObject == null) return;
|
||||
OwnerGameObject.SetActive(value);
|
||||
}
|
||||
|
||||
//其他的关于 RectTransform 相关的 不建议包一层
|
||||
//就直接 OwnerRectTransform. 使用Unity API 就可以了 没必要包一成
|
||||
//这么多方法 都有可能用到你都包一层嘛
|
||||
|
||||
#endregion
|
||||
|
||||
#region 生命周期
|
||||
|
||||
//UIBase 生命周期顺序 2
|
||||
protected virtual void UIBind()
|
||||
{
|
||||
}
|
||||
|
||||
//UIBase 生命周期顺序 3
|
||||
protected virtual void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
private void UIBaseInitialize()
|
||||
{
|
||||
CDETable.UIBaseStart = UIBaseStart;
|
||||
CDETable.UIBaseOnDestroy = UIBaseOnDestroy;
|
||||
try
|
||||
{
|
||||
SealedInitialize();
|
||||
UIBind();
|
||||
Initialize();
|
||||
if (ActiveSelf)
|
||||
UIBaseOnEnable();
|
||||
else
|
||||
UIBaseOnDisable();
|
||||
CDETable.UIBaseOnEnable = UIBaseOnEnable;
|
||||
CDETable.UIBaseOnDisable = UIBaseOnDisable;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
//UIBase 生命周期顺序 6
|
||||
protected virtual void Start()
|
||||
{
|
||||
}
|
||||
|
||||
private void UIBaseStart()
|
||||
{
|
||||
SealedStart();
|
||||
Start();
|
||||
}
|
||||
|
||||
//UIBase 生命周期顺序 4
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
}
|
||||
|
||||
private void UIBaseOnEnable()
|
||||
{
|
||||
OnEnable();
|
||||
}
|
||||
|
||||
//UIBase 生命周期顺序 4
|
||||
protected virtual void OnDisable()
|
||||
{
|
||||
}
|
||||
|
||||
private void UIBaseOnDisable()
|
||||
{
|
||||
OnDisable();
|
||||
}
|
||||
|
||||
//UIBase 生命周期顺序 7
|
||||
protected virtual void UnUIBind()
|
||||
{
|
||||
}
|
||||
|
||||
//UIBase 生命周期顺序 8
|
||||
protected virtual void OnDestroy()
|
||||
{
|
||||
}
|
||||
|
||||
private void UIBaseOnDestroy()
|
||||
{
|
||||
UnUIBind();
|
||||
OnDestroy();
|
||||
SealedOnDestroy();
|
||||
YIUIFactory.Destroy(this);
|
||||
}
|
||||
|
||||
#region 密封虚方法由(下级继承后)重写后密封 其他人可以不用关心
|
||||
|
||||
//这是给基类用的生命周期(BasePanel,BaseView) 为了防止有人重写时不调用基类 所以直接独立
|
||||
//没有什么穿插需求怎么办
|
||||
//基类会重写这个类且会密封你也调用不到
|
||||
//不要问为什么...
|
||||
//UIBase 生命周期顺序 1
|
||||
protected virtual void SealedInitialize()
|
||||
{
|
||||
}
|
||||
|
||||
//UIBase 生命周期顺序 5
|
||||
protected virtual void SealedStart()
|
||||
{
|
||||
}
|
||||
|
||||
//UIBase 生命周期顺序 9
|
||||
protected virtual void SealedOnDestroy()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Code/UIBase.cs.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Code/UIBase.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 24d50b68ce6649a0a6610ea2a05b8716
|
||||
timeCreated: 1681898395
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Component.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Component.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a2f25bf5c5441178d8817ff3edb096f
|
||||
timeCreated: 1689323009
|
||||
24
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Component/BaseComponent.cs
vendored
Normal file
24
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Component/BaseComponent.cs
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// 通用UI其他组件
|
||||
/// </summary>
|
||||
public partial class BaseComponent : UIBase
|
||||
{
|
||||
#region 密封生命周期根据需求扩展
|
||||
|
||||
protected sealed override void SealedInitialize()
|
||||
{
|
||||
}
|
||||
|
||||
protected sealed override void SealedStart()
|
||||
{
|
||||
}
|
||||
|
||||
protected sealed override void SealedOnDestroy()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Component/BaseComponent.cs.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Component/BaseComponent.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0903f39d5074d8abc2d5e4f94faa5d2
|
||||
timeCreated: 1683862460
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77084063f9744ffc8a6f028970bcf901
|
||||
timeCreated: 1689322970
|
||||
48
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel.cs
vendored
Normal file
48
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel.cs
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// 面板基类, 编辑器创建面板代码时自动带入
|
||||
/// </summary>
|
||||
public abstract partial class BasePanel : BaseWindow, IYIUIPanel
|
||||
{
|
||||
/// <summary>
|
||||
/// 所在层级
|
||||
/// </summary>
|
||||
public virtual EPanelLayer Layer => EPanelLayer.Panel;
|
||||
|
||||
/// <summary>
|
||||
/// 界面选项
|
||||
/// </summary>
|
||||
public virtual EPanelOption PanelOption => EPanelOption.None;
|
||||
|
||||
/// <summary>
|
||||
/// 堆栈操作
|
||||
/// </summary>
|
||||
public virtual EPanelStackOption StackOption => EPanelStackOption.Visible;
|
||||
|
||||
/// <summary>
|
||||
/// 优先级,用于同层级排序,
|
||||
/// 大的在前 小的在后
|
||||
/// 相同时 后添加的在前
|
||||
/// </summary>
|
||||
public virtual int Priority => 0;
|
||||
|
||||
#region 密封生命周期
|
||||
|
||||
protected sealed override void SealedInitialize()
|
||||
{
|
||||
InitPanelViewData();
|
||||
}
|
||||
|
||||
protected sealed override void SealedStart()
|
||||
{
|
||||
}
|
||||
|
||||
protected sealed override void SealedOnDestroy()
|
||||
{
|
||||
StopCountDownDestroyPanel();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel.cs.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef52b803bd61401897ae5642040cd9d6
|
||||
timeCreated: 1681898370
|
||||
88
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_Anim.cs
vendored
Normal file
88
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_Anim.cs
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// 动画
|
||||
/// </summary>
|
||||
public abstract partial class BasePanel
|
||||
{
|
||||
protected sealed override async UniTask SealedOnWindowOpenTween()
|
||||
{
|
||||
if (PanelMgr.IsLowQuality || WindowBanTween)
|
||||
{
|
||||
OnOpenTweenEnd();
|
||||
return;
|
||||
}
|
||||
|
||||
var foreverCode = WindowAllowOptionByTween ? 0 : m_PanelMgr.BanLayerOptionForever();
|
||||
try
|
||||
{
|
||||
await OnOpenTween();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"{UIResName} 打开动画执行报错 {e}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_PanelMgr.RecoverLayerOptionForever(foreverCode);
|
||||
OnOpenTweenEnd();
|
||||
}
|
||||
}
|
||||
|
||||
protected sealed override async UniTask SealedOnWindowCloseTween()
|
||||
{
|
||||
if (!ActiveSelf || PanelMgr.IsLowQuality || WindowBanTween)
|
||||
{
|
||||
OnCloseTweenEnd();
|
||||
return;
|
||||
}
|
||||
|
||||
var foreverCode = WindowAllowOptionByTween ? 0 : m_PanelMgr.BanLayerOptionForever();
|
||||
try
|
||||
{
|
||||
await OnCloseTween();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"{UIResName} 关闭动画执行报错 {e}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_PanelMgr.RecoverLayerOptionForever(foreverCode);
|
||||
OnCloseTweenEnd();
|
||||
}
|
||||
}
|
||||
|
||||
protected override async UniTask OnOpenTween()
|
||||
{
|
||||
await WindowFadeAnim.In(this);
|
||||
}
|
||||
|
||||
protected override async UniTask OnCloseTween()
|
||||
{
|
||||
await WindowFadeAnim.Out(this);
|
||||
}
|
||||
|
||||
protected override void OnOpenTweenStart()
|
||||
{
|
||||
OwnerGameObject.SetActive(true);
|
||||
}
|
||||
|
||||
protected override void OnOpenTweenEnd()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnCloseTweenStart()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnCloseTweenEnd()
|
||||
{
|
||||
OwnerGameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_Anim.cs.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_Anim.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 74416b8f584e45b4a9c436d96b5cc35f
|
||||
timeCreated: 1683889239
|
||||
30
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_Close.cs
vendored
Normal file
30
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_Close.cs
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// 关闭
|
||||
/// </summary>
|
||||
public abstract partial class BasePanel
|
||||
{
|
||||
public void Close(bool tween = true, bool ignoreElse = false)
|
||||
{
|
||||
CloseAsync(tween, ignoreElse).Forget();
|
||||
}
|
||||
|
||||
public async UniTask CloseAsync(bool tween = true, bool ignoreElse = false)
|
||||
{
|
||||
await m_PanelMgr.ClosePanelAsync(UIResName, tween, ignoreElse);
|
||||
}
|
||||
|
||||
protected void Home<T>(bool tween = true) where T : BasePanel
|
||||
{
|
||||
m_PanelMgr.HomePanel<T>(tween).Forget();
|
||||
}
|
||||
|
||||
protected void Home(string homeName, bool tween = true)
|
||||
{
|
||||
m_PanelMgr.HomePanel(homeName, tween).Forget();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_Close.cs.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_Close.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03365dc283b74259b6b1365f3507aa70
|
||||
timeCreated: 1683886901
|
||||
42
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_CloseView.cs
vendored
Normal file
42
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_CloseView.cs
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
public abstract partial class BasePanel
|
||||
{
|
||||
public void CloseView<T>(bool tween = true)
|
||||
where T : BaseView
|
||||
{
|
||||
CloseViewAsync<T>(tween).Forget();
|
||||
}
|
||||
|
||||
public void CloseView(string resName, bool tween = true)
|
||||
{
|
||||
CloseViewAsync(resName, tween).Forget();
|
||||
}
|
||||
|
||||
public async UniTask<bool> CloseViewAsync<TView>(bool tween = true)
|
||||
where TView : BaseView
|
||||
{
|
||||
var (exist, entity) = ExistView<TView>();
|
||||
if (!exist) return false;
|
||||
return await CloseViewAsync(entity, tween);
|
||||
}
|
||||
|
||||
public async UniTask<bool> CloseViewAsync(string resName, bool tween = true)
|
||||
{
|
||||
var (exist, entity) = ExistView(resName);
|
||||
if (!exist) return false;
|
||||
return await CloseViewAsync(entity, tween);
|
||||
}
|
||||
|
||||
private async UniTask<bool> CloseViewAsync(BaseView view, bool tween)
|
||||
{
|
||||
if (view == null) return false;
|
||||
await view.CloseAsync(tween);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8524a28809b546008658b643b82d5f8e
|
||||
timeCreated: 1716112439
|
||||
236
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_Open.cs
vendored
Normal file
236
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_Open.cs
vendored
Normal file
@@ -0,0 +1,236 @@
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
public abstract partial class BasePanel
|
||||
{
|
||||
#region Open 由PanelMgr调用
|
||||
|
||||
/// <summary>
|
||||
/// 使用基础Open 打开类
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async UniTask<bool> UseBaseOpen()
|
||||
{
|
||||
if (!WindowCanUseBaseOpen)
|
||||
{
|
||||
Debug.LogError($"当前传入的参数不支持 并未实现这个打开方式 且不允许使用基础Open打开 请检查");
|
||||
return false;
|
||||
}
|
||||
|
||||
return await Open();
|
||||
}
|
||||
|
||||
public async UniTask<bool> Open()
|
||||
{
|
||||
SetActive(true);
|
||||
|
||||
var success = false;
|
||||
|
||||
if (!WindowHaveIOpenAllowOpen && this is IYIUIOpen)
|
||||
{
|
||||
Debug.LogError($"当前Panel 有其他IOpen 接口 需要参数传入 不允许直接调用Open");
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
success = await OnOpen();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName{UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
await InternalOnWindowOpenTween();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
public async UniTask<bool> Open(ParamVo param)
|
||||
{
|
||||
if (WindowBanParamOpen)
|
||||
{
|
||||
Debug.LogError($"当前禁止使用ParamOpen 请检查");
|
||||
return false;
|
||||
}
|
||||
|
||||
SetActive(true);
|
||||
|
||||
var success = false;
|
||||
|
||||
try
|
||||
{
|
||||
success = await OnOpen(param);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName{UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
await InternalOnWindowOpenTween();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
public async UniTask<bool> Open<P1>(P1 p1)
|
||||
{
|
||||
SetActive(true);
|
||||
|
||||
var success = false;
|
||||
|
||||
if (this is IYIUIOpen<P1> panel)
|
||||
{
|
||||
try
|
||||
{
|
||||
success = await panel.OnOpen(p1);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName{UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return await UseBaseOpen();
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
await InternalOnWindowOpenTween();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
public async UniTask<bool> Open<P1, P2>(P1 p1, P2 p2)
|
||||
{
|
||||
SetActive(true);
|
||||
|
||||
var success = false;
|
||||
|
||||
if (this is IYIUIOpen<P1, P2> panel)
|
||||
{
|
||||
try
|
||||
{
|
||||
success = await panel.OnOpen(p1, p2);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName{UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return await UseBaseOpen();
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
await InternalOnWindowOpenTween();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
public async UniTask<bool> Open<P1, P2, P3>(P1 p1, P2 p2, P3 p3)
|
||||
{
|
||||
SetActive(true);
|
||||
|
||||
var success = false;
|
||||
|
||||
if (this is IYIUIOpen<P1, P2, P3> panel)
|
||||
{
|
||||
try
|
||||
{
|
||||
success = await panel.OnOpen(p1, p2, p3);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName{UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return await UseBaseOpen();
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
await InternalOnWindowOpenTween();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
public async UniTask<bool> Open<P1, P2, P3, P4>(P1 p1, P2 p2, P3 p3, P4 p4)
|
||||
{
|
||||
SetActive(true);
|
||||
|
||||
var success = false;
|
||||
|
||||
if (this is IYIUIOpen<P1, P2, P3, P4> panel)
|
||||
{
|
||||
try
|
||||
{
|
||||
success = await panel.OnOpen(p1, p2, p3, p4);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName{UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return await UseBaseOpen();
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
await InternalOnWindowOpenTween();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
public async UniTask<bool> Open<P1, P2, P3, P4, P5>(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
|
||||
{
|
||||
SetActive(true);
|
||||
|
||||
var success = false;
|
||||
|
||||
if (this is IYIUIOpen<P1, P2, P3, P4, P5> panel)
|
||||
{
|
||||
try
|
||||
{
|
||||
success = await panel.OnOpen(p1, p2, p3, p4, p5);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName{UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return await UseBaseOpen();
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
await InternalOnWindowOpenTween();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_Open.cs.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_Open.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2af119f866046dc87febc299cdb2644
|
||||
timeCreated: 1683799029
|
||||
210
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_OpenView.cs
vendored
Normal file
210
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_OpenView.cs
vendored
Normal file
@@ -0,0 +1,210 @@
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using YIUIBind;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// 部类 界面拆分数据
|
||||
/// </summary>
|
||||
public abstract partial class BasePanel
|
||||
{
|
||||
private UIPanelSplitData m_PanelSplitData;
|
||||
|
||||
private Dictionary<string, BaseView> m_ExistView = new Dictionary<string, BaseView>();
|
||||
|
||||
private Dictionary<string, RectTransform> m_ViewParent = new Dictionary<string, RectTransform>();
|
||||
|
||||
private void InitPanelViewData()
|
||||
{
|
||||
m_ExistView.Clear();
|
||||
m_ViewParent.Clear();
|
||||
m_PanelSplitData = CDETable.PanelSplitData;
|
||||
CreateCommonView();
|
||||
AddViewParent(m_PanelSplitData.AllCommonView);
|
||||
AddViewParent(m_PanelSplitData.AllCreateView);
|
||||
AddViewParent(m_PanelSplitData.AllPopupView);
|
||||
}
|
||||
|
||||
private void AddViewParent(List<RectTransform> listParent)
|
||||
{
|
||||
foreach (var parent in listParent)
|
||||
{
|
||||
var viewName = parent.name.Replace(UIStaticHelper.UIParentName, "");
|
||||
m_ViewParent.Add(viewName, parent);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateCommonView()
|
||||
{
|
||||
foreach (var commonParentView in m_PanelSplitData.AllCommonView)
|
||||
{
|
||||
var viewName = commonParentView.name.Replace(UIStaticHelper.UIParentName, "");
|
||||
|
||||
//通用view的名称是不允许修改的 如果修改了 那么就创建一个新的
|
||||
var viewTsf = commonParentView.FindChildByName(viewName);
|
||||
if (viewTsf == null)
|
||||
{
|
||||
Debug.LogError($"{viewName} 当前通用View 不存在于父级下 所以无法自动创建 将会动态创建");
|
||||
continue;
|
||||
}
|
||||
|
||||
//通用创建 这个时候通用UI一定是没有创建的 否则就有问题
|
||||
var viewBase = YIUIFactory.CreateCommon(UIPkgName, viewName, viewTsf.gameObject);
|
||||
if (viewBase == null)continue;
|
||||
|
||||
viewTsf.gameObject.SetActive(false);
|
||||
|
||||
switch (viewBase)
|
||||
{
|
||||
case BaseView baseView:
|
||||
m_ExistView.Add(viewName, baseView);
|
||||
break;
|
||||
default:
|
||||
Debug.LogError($"{viewName} 不应该存在的错误 当前创建的View 不是BaseView");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private RectTransform GetViewParent(string viewName)
|
||||
{
|
||||
m_ViewParent.TryGetValue(viewName, out var value);
|
||||
return value;
|
||||
}
|
||||
|
||||
private async UniTask<T> GetView<T>() where T : BaseView
|
||||
{
|
||||
var viewName = typeof(T).Name;
|
||||
var parent = GetViewParent(viewName);
|
||||
if (parent == null)
|
||||
{
|
||||
Debug.LogError($"不存在这个View 请检查 {viewName}");
|
||||
return null;
|
||||
}
|
||||
|
||||
using var asyncLock = await AsyncLockMgr.Inst.Wait(viewName.GetHashCode());
|
||||
|
||||
if (m_ExistView.ContainsKey(viewName))
|
||||
{
|
||||
return (T)m_ExistView[viewName];
|
||||
}
|
||||
|
||||
var view = await YIUIFactory.InstantiateAsync<T>(parent);
|
||||
|
||||
m_ExistView.Add(viewName, view);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
public (bool, BaseView) ExistView<T>() where T : BaseView
|
||||
{
|
||||
var data = UIBindHelper.GetBindVoByType<T>();
|
||||
if (data == null) return (false, null);
|
||||
var vo = data.Value;
|
||||
|
||||
var viewName = vo.ResName;
|
||||
var viewParent = GetViewParent(viewName);
|
||||
if (viewParent == null)
|
||||
{
|
||||
Debug.LogError($"不存在这个View 请检查 {viewName}");
|
||||
return (false, null);
|
||||
}
|
||||
|
||||
if (m_ExistView.TryGetValue(viewName, out var baseView))
|
||||
{
|
||||
return (true, baseView);
|
||||
}
|
||||
|
||||
return (false, null);
|
||||
}
|
||||
|
||||
public (bool, BaseView) ExistView(string viewName)
|
||||
{
|
||||
var viewParent = GetViewParent(viewName);
|
||||
if (viewParent == null)
|
||||
{
|
||||
Debug.LogError($"不存在这个View 请检查 {viewName}");
|
||||
return (false, null);
|
||||
}
|
||||
|
||||
if (m_ExistView.TryGetValue(viewName, out var baseView))
|
||||
{
|
||||
return (true, baseView);
|
||||
}
|
||||
|
||||
return (false, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开之前
|
||||
/// </summary>
|
||||
private async UniTask OpenViewBefore(BaseView view)
|
||||
{
|
||||
if (!view.WindowFirstOpen)
|
||||
{
|
||||
await CloseLastView(view);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开之后
|
||||
/// </summary>
|
||||
private async UniTask OpenViewAfter(BaseView view, bool success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
if (view.WindowFirstOpen)
|
||||
{
|
||||
await CloseLastView(view);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
view.Close(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭上一个
|
||||
/// </summary>
|
||||
/// <param name="view">当前</param>
|
||||
private async UniTask CloseLastView(BaseView view)
|
||||
{
|
||||
//其他需要被忽略
|
||||
if (view.ViewWindowType != EViewWindowType.View)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//View只有切换没有关闭
|
||||
var skipTween = view.WindowSkipOtherCloseTween;
|
||||
|
||||
if (u_CurrentOpenView != null && u_CurrentOpenView != view)
|
||||
{
|
||||
//View 没有自动回退功能 比如AView 关闭 自动吧上一个BView 给打开 没有这种需求 也不能有这个需求
|
||||
//只能有 打开一个新View 上一个View的自动处理 99% 都是吧上一个隐藏即可
|
||||
//外部就只需要关心 打开 A B C 即可
|
||||
//因为这是View 不是 Panel
|
||||
switch (u_CurrentOpenView.StackOption)
|
||||
{
|
||||
case EViewStackOption.None:
|
||||
break;
|
||||
case EViewStackOption.Visible:
|
||||
u_CurrentOpenView.SetActive(false);
|
||||
break;
|
||||
case EViewStackOption.VisibleTween:
|
||||
await u_CurrentOpenView.CloseAsync(!skipTween);
|
||||
break;
|
||||
default:
|
||||
Debug.LogError($"新增类型未实现 {u_CurrentOpenView.StackOption}");
|
||||
u_CurrentOpenView.SetActive(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
u_CurrentOpenView = view;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d35290fb77ef4c6eb52caee150b65c39
|
||||
timeCreated: 1683795537
|
||||
154
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_OpenView_Async.cs
vendored
Normal file
154
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_OpenView_Async.cs
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
//打开泛型 异步
|
||||
public abstract partial class BasePanel
|
||||
{
|
||||
protected async UniTask<T> OpenViewAsync<T>()
|
||||
where T : BaseView, new()
|
||||
{
|
||||
var view = await GetView<T>();
|
||||
if (view == null) return default;
|
||||
|
||||
var success = false;
|
||||
|
||||
await OpenViewBefore(view);
|
||||
|
||||
try
|
||||
{
|
||||
success = await view.Open();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName={view.UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
|
||||
await OpenViewAfter(view, success);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
protected async UniTask<T> OpenViewAsync<T, P1>(P1 p1)
|
||||
where T : BaseView, IYIUIOpen<P1>, new()
|
||||
{
|
||||
var view = await GetView<T>();
|
||||
if (view == null) return default;
|
||||
|
||||
var success = false;
|
||||
|
||||
await OpenViewBefore(view);
|
||||
|
||||
try
|
||||
{
|
||||
success = await view.Open(p1);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName={view.UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
|
||||
await OpenViewAfter(view, success);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
protected async UniTask<T> OpenViewAsync<T, P1, P2>(P1 p1, P2 p2)
|
||||
where T : BaseView, IYIUIOpen<P1, P2>, new()
|
||||
{
|
||||
var view = await GetView<T>();
|
||||
if (view == null) return default;
|
||||
|
||||
var success = false;
|
||||
|
||||
await OpenViewBefore(view);
|
||||
|
||||
try
|
||||
{
|
||||
success = await view.Open(p1, p2);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName={view.UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
|
||||
await OpenViewAfter(view, success);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
protected async UniTask<T> OpenViewAsync<T, P1, P2, P3>(P1 p1, P2 p2, P3 p3)
|
||||
where T : BaseView, IYIUIOpen<P1, P2, P3>, new()
|
||||
{
|
||||
var view = await GetView<T>();
|
||||
if (view == null) return default;
|
||||
|
||||
var success = false;
|
||||
|
||||
await OpenViewBefore(view);
|
||||
|
||||
try
|
||||
{
|
||||
success = await view.Open(p1, p2, p3);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName={view.UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
|
||||
await OpenViewAfter(view, success);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
protected async UniTask<T> OpenViewAsync<T, P1, P2, P3, P4>(P1 p1, P2 p2, P3 p3, P4 p4)
|
||||
where T : BaseView, IYIUIOpen<P1, P2, P3, P4>, new()
|
||||
{
|
||||
var view = await GetView<T>();
|
||||
if (view == null) return default;
|
||||
|
||||
var success = false;
|
||||
|
||||
await OpenViewBefore(view);
|
||||
|
||||
try
|
||||
{
|
||||
success = await view.Open(p1, p2, p3, p4);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName={view.UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
|
||||
await OpenViewAfter(view, success);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
protected async UniTask<T> OpenViewAsync<T, P1, P2, P3, P4, P5>(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
|
||||
where T : BaseView, IYIUIOpen<P1, P2, P3, P4, P5>, new()
|
||||
{
|
||||
var view = await GetView<T>();
|
||||
if (view == null) return default;
|
||||
|
||||
var success = false;
|
||||
|
||||
await OpenViewBefore(view);
|
||||
|
||||
try
|
||||
{
|
||||
success = await view.Open(p1, p2, p3, p4, p5);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName={view.UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
|
||||
await OpenViewAfter(view, success);
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b4ee8db93194df8b9c7988dca3701df
|
||||
timeCreated: 1685587228
|
||||
@@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// 部类 界面拆分数据
|
||||
/// </summary>
|
||||
public abstract partial class BasePanel
|
||||
{
|
||||
private async UniTask<BaseView> GetView(string viewName)
|
||||
{
|
||||
var parent = GetViewParent(viewName);
|
||||
if (parent == null)
|
||||
{
|
||||
Debug.LogError($"不存在这个View 请检查 {viewName}");
|
||||
return null;
|
||||
}
|
||||
|
||||
using var asyncLock = await AsyncLockMgr.Inst.Wait(viewName.GetHashCode());
|
||||
|
||||
if (m_ExistView.ContainsKey(viewName))
|
||||
{
|
||||
return m_ExistView[viewName];
|
||||
}
|
||||
|
||||
var value = UIBindHelper.GetBindVoByPath(UIPkgName, viewName);
|
||||
if (value == null) return null;
|
||||
var bindVo = value.Value;
|
||||
var view = (BaseView)await YIUIFactory.InstantiateAsync(bindVo, parent);
|
||||
m_ExistView.Add(viewName, view);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
#region 打开泛型
|
||||
|
||||
protected async UniTask<BaseView> OpenViewAsync(string viewName, object param = null)
|
||||
{
|
||||
var view = await GetView(viewName);
|
||||
if (view == null) return null;
|
||||
|
||||
var success = false;
|
||||
|
||||
await OpenViewBefore(view);
|
||||
|
||||
try
|
||||
{
|
||||
var p = ParamVo.Get(param);
|
||||
success = await view.Open(p);
|
||||
ParamVo.Put(p);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName={view.UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
|
||||
await OpenViewAfter(view, success);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
protected async UniTask<BaseView> OpenViewAsync(string viewName, object param1, object param2)
|
||||
{
|
||||
var paramList = ListPool<object>.Get();
|
||||
paramList.Add(param1);
|
||||
paramList.Add(param2);
|
||||
var view = await OpenViewAsync(viewName, paramList);
|
||||
ListPool<object>.Put(paramList);
|
||||
return view;
|
||||
}
|
||||
|
||||
protected async UniTask<BaseView> OpenViewAsync(string viewName, object param1, object param2, object param3)
|
||||
{
|
||||
var paramList = ListPool<object>.Get();
|
||||
paramList.Add(param1);
|
||||
paramList.Add(param2);
|
||||
paramList.Add(param3);
|
||||
var view = await OpenViewAsync(viewName, paramList);
|
||||
ListPool<object>.Put(paramList);
|
||||
return view;
|
||||
}
|
||||
|
||||
protected async UniTask<BaseView> OpenViewAsync(string viewName, object param1, object param2, object param3,
|
||||
object param4)
|
||||
{
|
||||
var paramList = ListPool<object>.Get();
|
||||
paramList.Add(param1);
|
||||
paramList.Add(param2);
|
||||
paramList.Add(param3);
|
||||
paramList.Add(param4);
|
||||
var view = await OpenViewAsync(viewName, paramList);
|
||||
ListPool<object>.Put(paramList);
|
||||
return view;
|
||||
}
|
||||
|
||||
protected async UniTask<BaseView> OpenViewAsync(string viewName, object param1, object param2, object param3,
|
||||
object param4, params object[] paramMore)
|
||||
{
|
||||
var paramList = ListPool<object>.Get();
|
||||
paramList.Add(param1);
|
||||
paramList.Add(param2);
|
||||
paramList.Add(param3);
|
||||
paramList.Add(param4);
|
||||
if (paramMore.Length > 0)
|
||||
{
|
||||
paramList.AddRange(paramMore);
|
||||
}
|
||||
|
||||
var view = await OpenViewAsync(viewName, paramList);
|
||||
ListPool<object>.Put(paramList);
|
||||
return view;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2dbb82e78ed84937b1757dc057ac2678
|
||||
timeCreated: 1683809072
|
||||
@@ -0,0 +1,148 @@
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
public abstract partial class BasePanel
|
||||
{
|
||||
protected async UniTask<BaseView> OpenViewAsync(string viewName)
|
||||
{
|
||||
var view = await GetView(viewName);
|
||||
if (view == null) return default;
|
||||
|
||||
var success = false;
|
||||
|
||||
await OpenViewBefore(view);
|
||||
|
||||
try
|
||||
{
|
||||
success = await view.Open();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName={view.UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
|
||||
await OpenViewAfter(view, success);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
protected async UniTask<BaseView> OpenViewAsync<P1>(string viewName, P1 p1)
|
||||
{
|
||||
var view = await GetView(viewName);
|
||||
if (view == null) return default;
|
||||
|
||||
var success = false;
|
||||
|
||||
await OpenViewBefore(view);
|
||||
|
||||
try
|
||||
{
|
||||
success = await view.Open(p1);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName={view.UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
|
||||
await OpenViewAfter(view, success);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
protected async UniTask<BaseView> OpenViewAsync<P1, P2>(string viewName, P1 p1, P2 p2)
|
||||
{
|
||||
var view = await GetView(viewName);
|
||||
if (view == null) return default;
|
||||
|
||||
var success = false;
|
||||
|
||||
await OpenViewBefore(view);
|
||||
|
||||
try
|
||||
{
|
||||
success = await view.Open(p1, p2);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName={view.UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
|
||||
await OpenViewAfter(view, success);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
protected async UniTask<BaseView> OpenViewAsync<P1, P2, P3>(string viewName, P1 p1, P2 p2, P3 p3)
|
||||
{
|
||||
var view = await GetView(viewName);
|
||||
if (view == null) return default;
|
||||
|
||||
var success = false;
|
||||
|
||||
await OpenViewBefore(view);
|
||||
|
||||
try
|
||||
{
|
||||
success = await view.Open(p1, p2, p3);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName={view.UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
|
||||
await OpenViewAfter(view, success);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
protected async UniTask<BaseView> OpenViewAsync<P1, P2, P3, P4>(string viewName, P1 p1, P2 p2, P3 p3, P4 p4)
|
||||
{
|
||||
var view = await GetView(viewName);
|
||||
if (view == null) return default;
|
||||
|
||||
var success = false;
|
||||
|
||||
await OpenViewBefore(view);
|
||||
|
||||
try
|
||||
{
|
||||
success = await view.Open(p1, p2, p3, p4);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName={view.UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
|
||||
await OpenViewAfter(view, success);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
protected async UniTask<BaseView> OpenViewAsync<P1, P2, P3, P4, P5>(
|
||||
string viewName, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
|
||||
{
|
||||
var view = await GetView(viewName);
|
||||
if (view == null) return default;
|
||||
|
||||
var success = false;
|
||||
|
||||
await OpenViewBefore(view);
|
||||
|
||||
try
|
||||
{
|
||||
success = await view.Open(p1, p2, p3, p4, p5);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName={view.UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
|
||||
await OpenViewAfter(view, success);
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62230f4010824c21b6295a2b6aa6277a
|
||||
timeCreated: 1683881474
|
||||
47
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_OpenView_Sync.cs
vendored
Normal file
47
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_OpenView_Sync.cs
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// 打开泛型 同步方法 内部还是异步打开
|
||||
/// 不想提供快捷操作可以删除此类
|
||||
/// </summary>
|
||||
public abstract partial class BasePanel
|
||||
{
|
||||
protected void OpenView<T>()
|
||||
where T : BaseView, new()
|
||||
{
|
||||
OpenViewAsync<T>().Forget();
|
||||
}
|
||||
|
||||
protected void OpenView<T, P1>(P1 p1)
|
||||
where T : BaseView, IYIUIOpen<P1>, new()
|
||||
{
|
||||
OpenViewAsync<T, P1>(p1).Forget();
|
||||
}
|
||||
|
||||
protected void OpenView<T, P1, P2>(P1 p1, P2 p2)
|
||||
where T : BaseView, IYIUIOpen<P1, P2>, new()
|
||||
{
|
||||
OpenViewAsync<T, P1, P2>(p1, p2).Forget();
|
||||
}
|
||||
|
||||
protected void OpenView<T, P1, P2, P3>(P1 p1, P2 p2, P3 p3)
|
||||
where T : BaseView, IYIUIOpen<P1, P2, P3>, new()
|
||||
{
|
||||
OpenViewAsync<T, P1, P2, P3>(p1, p2, p3).Forget();
|
||||
}
|
||||
|
||||
protected void OpenView<T, P1, P2, P3, P4>(P1 p1, P2 p2, P3 p3, P4 p4)
|
||||
where T : BaseView, IYIUIOpen<P1, P2, P3, P4>, new()
|
||||
{
|
||||
OpenViewAsync<T, P1, P2, P3, P4>(p1, p2, p3, p4).Forget();
|
||||
}
|
||||
|
||||
protected void OpenView<T, P1, P2, P3, P4, P5>(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
|
||||
where T : BaseView, IYIUIOpen<P1, P2, P3, P4, P5>, new()
|
||||
{
|
||||
OpenViewAsync<T, P1, P2, P3, P4, P5>(p1, p2, p3, p4, p5).Forget();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 360f18fc00e744489e2e5a2d15f49951
|
||||
timeCreated: 1685587311
|
||||
157
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_OpenView_Type.cs
vendored
Normal file
157
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_OpenView_Type.cs
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
using YIUIFramework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
public abstract partial class BasePanel
|
||||
{
|
||||
private async UniTask<BaseView> GetView(Type viewType)
|
||||
{
|
||||
var viewName = viewType.Name;
|
||||
return await GetView(viewName);
|
||||
}
|
||||
|
||||
protected async UniTask<BaseView> OpenViewAsync(Type viewType)
|
||||
{
|
||||
var view = await GetView(viewType);
|
||||
if (view == null) return default;
|
||||
|
||||
var success = false;
|
||||
|
||||
await OpenViewBefore(view);
|
||||
|
||||
try
|
||||
{
|
||||
success = await view.Open();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName={view.UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
|
||||
await OpenViewAfter(view, success);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
protected async UniTask<BaseView> OpenViewAsync<P1>(Type viewType, P1 p1)
|
||||
{
|
||||
var view = await GetView(viewType);
|
||||
if (view == null) return default;
|
||||
|
||||
var success = false;
|
||||
|
||||
await OpenViewBefore(view);
|
||||
|
||||
try
|
||||
{
|
||||
success = await view.Open(p1);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName={view.UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
|
||||
await OpenViewAfter(view, success);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
protected async UniTask<BaseView> OpenViewAsync<P1, P2>(Type viewType, P1 p1, P2 p2)
|
||||
{
|
||||
var view = await GetView(viewType);
|
||||
if (view == null) return default;
|
||||
|
||||
var success = false;
|
||||
|
||||
await OpenViewBefore(view);
|
||||
|
||||
try
|
||||
{
|
||||
success = await view.Open(p1, p2);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName={view.UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
|
||||
await OpenViewAfter(view, success);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
protected async UniTask<BaseView> OpenViewAsync<P1, P2, P3>(Type viewType, P1 p1, P2 p2, P3 p3)
|
||||
{
|
||||
var view = await GetView(viewType);
|
||||
if (view == null) return default;
|
||||
|
||||
var success = false;
|
||||
|
||||
await OpenViewBefore(view);
|
||||
|
||||
try
|
||||
{
|
||||
success = await view.Open(p1, p2, p3);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName={view.UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
|
||||
await OpenViewAfter(view, success);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
protected async UniTask<BaseView> OpenViewAsync<P1, P2, P3, P4>(Type viewType, P1 p1, P2 p2, P3 p3, P4 p4)
|
||||
{
|
||||
var view = await GetView(viewType);
|
||||
if (view == null) return default;
|
||||
|
||||
var success = false;
|
||||
|
||||
await OpenViewBefore(view);
|
||||
|
||||
try
|
||||
{
|
||||
success = await view.Open(p1, p2, p3, p4);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName={view.UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
|
||||
await OpenViewAfter(view, success);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
protected async UniTask<BaseView> OpenViewAsync<P1, P2, P3, P4, P5>(
|
||||
Type viewType, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
|
||||
{
|
||||
var view = await GetView(viewType);
|
||||
if (view == null) return default;
|
||||
|
||||
var success = false;
|
||||
|
||||
await OpenViewBefore(view);
|
||||
|
||||
try
|
||||
{
|
||||
success = await view.Open(p1, p2, p3, p4, p5);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName={view.UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
|
||||
await OpenViewAfter(view, success);
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d92b104aba75473fae7b8724eb9b2a6d
|
||||
timeCreated: 1683879762
|
||||
20
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_Option_HasFlage.cs
vendored
Normal file
20
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_Option_HasFlage.cs
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace YIUIFramework
|
||||
{
|
||||
public abstract partial class BasePanel
|
||||
{
|
||||
//容器类界面 //比如伤害飘字 此类界面如果做到panel层会被特殊处理 建议还是不要放到panel层
|
||||
public virtual bool PanelContainer => PanelOption.HasFlag(EPanelOption.Container);
|
||||
|
||||
//永久缓存界面 //永远不会被摧毁 与禁止关闭不同这个可以关闭 只是不销毁 也可相当于无限长的倒计时
|
||||
public virtual bool PanelForeverCache => PanelOption.HasFlag(EPanelOption.ForeverCache);
|
||||
|
||||
//倒计时缓存界面 //被关闭后X秒之后在摧毁 否则理解摧毁
|
||||
public virtual bool PanelTimeCache => PanelOption.HasFlag(EPanelOption.TimeCache);
|
||||
|
||||
//禁止关闭的界面 //是需要一直存在的你可以隐藏 但是你不能摧毁
|
||||
public virtual bool PanelDisClose => PanelOption.HasFlag(EPanelOption.DisClose);
|
||||
|
||||
//忽略返回 返回操作会跳过这个界面 //他的打开与关闭不会触发返回功能 堆栈功能
|
||||
public virtual bool PanelIgnoreBack => PanelOption.HasFlag(EPanelOption.IgnoreBack);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b49f828695524bdf831f77cc731818c1
|
||||
timeCreated: 1689325011
|
||||
49
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_TimeDestroy.cs
vendored
Normal file
49
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_TimeDestroy.cs
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// 倒计时摧毁面板 适用于倒计时缓存界面
|
||||
/// </summary>
|
||||
public abstract partial class BasePanel
|
||||
{
|
||||
protected virtual float CachePanelTime => 10;
|
||||
|
||||
private CancellationTokenSource m_Cts;
|
||||
|
||||
internal void CacheTimeCountDownDestroyPanel()
|
||||
{
|
||||
StopCountDownDestroyPanel();
|
||||
m_Cts = new CancellationTokenSource();
|
||||
DoCountDownDestroyPanel(m_Cts.Token).Forget();
|
||||
}
|
||||
|
||||
internal void StopCountDownDestroyPanel()
|
||||
{
|
||||
if (m_Cts == null) return;
|
||||
|
||||
m_Cts.Cancel();
|
||||
m_Cts.Dispose();
|
||||
m_Cts = null;
|
||||
}
|
||||
|
||||
private async UniTaskVoid DoCountDownDestroyPanel(CancellationToken token)
|
||||
{
|
||||
try
|
||||
{
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(CachePanelTime), cancellationToken: token);
|
||||
}
|
||||
catch (OperationCanceledException e)
|
||||
{
|
||||
//取消倒计时 正常操作不需要日志
|
||||
return;
|
||||
}
|
||||
|
||||
m_Cts = null;
|
||||
UnityEngine.Object.Destroy(OwnerGameObject);
|
||||
PanelMgr.Inst.RemoveUIReset(UIResName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a45c498dabd405e9527697d9022de97
|
||||
timeCreated: 1684145311
|
||||
15
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_View.cs
vendored
Normal file
15
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_View.cs
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace YIUIFramework
|
||||
{
|
||||
public abstract partial class BasePanel
|
||||
{
|
||||
/// <summary>
|
||||
/// 当前已打开的UI 不包含弹窗
|
||||
/// </summary>
|
||||
protected BaseView u_CurrentOpenView;
|
||||
|
||||
/// <summary>
|
||||
/// 外界可判断的当前打开的view名字
|
||||
/// </summary>
|
||||
public string CurrentOpenViewName => u_CurrentOpenView?.UIResName ?? "";
|
||||
}
|
||||
}
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_View.cs.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Panel/BasePanel_View.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aac7aa8d5f1149a9a3125d82fc54920b
|
||||
timeCreated: 1683878928
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/View.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/View.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f9458c6e64841389a6a071d118af460
|
||||
timeCreated: 1689322985
|
||||
25
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/View/BaseView.cs
vendored
Normal file
25
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/View/BaseView.cs
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
namespace YIUIFramework
|
||||
{
|
||||
public partial class BaseView : BaseWindow, IYIUIView
|
||||
{
|
||||
public virtual EViewWindowType ViewWindowType => EViewWindowType.View;
|
||||
|
||||
public virtual EViewStackOption StackOption => EViewStackOption.Visible;
|
||||
|
||||
#region 密封生命周期
|
||||
|
||||
protected sealed override void SealedInitialize()
|
||||
{
|
||||
}
|
||||
|
||||
protected sealed override void SealedStart()
|
||||
{
|
||||
}
|
||||
|
||||
protected sealed override void SealedOnDestroy()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/View/BaseView.cs.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/View/BaseView.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8fce5356e45247d098a80b33ae50d355
|
||||
timeCreated: 1681899010
|
||||
85
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/View/BaseView_Anim.cs
vendored
Normal file
85
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/View/BaseView_Anim.cs
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
public partial class BaseView
|
||||
{
|
||||
protected sealed override async UniTask SealedOnWindowOpenTween()
|
||||
{
|
||||
if (PanelMgr.IsLowQuality || WindowBanTween)
|
||||
{
|
||||
OnOpenTweenEnd();
|
||||
return;
|
||||
}
|
||||
|
||||
var foreverCode = WindowAllowOptionByTween ? 0 : m_PanelMgr.BanLayerOptionForever();
|
||||
try
|
||||
{
|
||||
await OnOpenTween();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"{UIResName} 打开动画执行报错 {e}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_PanelMgr.RecoverLayerOptionForever(foreverCode);
|
||||
OnOpenTweenEnd();
|
||||
}
|
||||
}
|
||||
|
||||
protected sealed override async UniTask SealedOnWindowCloseTween()
|
||||
{
|
||||
if (!ActiveSelf || PanelMgr.IsLowQuality || WindowBanTween)
|
||||
{
|
||||
OnCloseTweenEnd();
|
||||
return;
|
||||
}
|
||||
|
||||
var foreverCode = WindowAllowOptionByTween ? 0 : m_PanelMgr.BanLayerOptionForever();
|
||||
try
|
||||
{
|
||||
await OnCloseTween();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"{UIResName} 关闭动画执行报错 {e}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_PanelMgr.RecoverLayerOptionForever(foreverCode);
|
||||
OnCloseTweenEnd();
|
||||
}
|
||||
}
|
||||
|
||||
protected override async UniTask OnOpenTween()
|
||||
{
|
||||
await UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
protected override async UniTask OnCloseTween()
|
||||
{
|
||||
await UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
protected override void OnOpenTweenStart()
|
||||
{
|
||||
OwnerGameObject.SetActive(true);
|
||||
}
|
||||
|
||||
protected override void OnOpenTweenEnd()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnCloseTweenStart()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnCloseTweenEnd()
|
||||
{
|
||||
OwnerGameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/View/BaseView_Anim.cs.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/View/BaseView_Anim.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d10269ae02e548d393b7683b30b9d806
|
||||
timeCreated: 1684119736
|
||||
18
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/View/BaseView_Close.cs
vendored
Normal file
18
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/View/BaseView_Close.cs
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
public partial class BaseView
|
||||
{
|
||||
public void Close(bool tween = true, bool ignoreElse = false)
|
||||
{
|
||||
CloseAsync(tween).Forget();
|
||||
}
|
||||
|
||||
public async UniTask CloseAsync(bool tween = true)
|
||||
{
|
||||
await InternalOnWindowCloseTween(tween);
|
||||
OnWindowClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/View/BaseView_Close.cs.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/View/BaseView_Close.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5487f84a0fa4482dab277c0ee07f415c
|
||||
timeCreated: 1684119708
|
||||
239
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/View/BaseView_Open.cs
vendored
Normal file
239
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/View/BaseView_Open.cs
vendored
Normal file
@@ -0,0 +1,239 @@
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// OpenView 由BasePanel调用
|
||||
/// </summary>
|
||||
public partial class BaseView
|
||||
{
|
||||
#region Open 由BasePanel调用
|
||||
|
||||
/// <summary>
|
||||
/// 使用基础Open 打开类
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async UniTask<bool> UseBaseOpen()
|
||||
{
|
||||
if (!WindowCanUseBaseOpen)
|
||||
{
|
||||
Debug.LogError($"当前传入的参数不支持 并未实现这个打开方式 且不允许使用基础Open打开 请检查");
|
||||
return false;
|
||||
}
|
||||
|
||||
return await Open();
|
||||
}
|
||||
|
||||
public async UniTask<bool> Open()
|
||||
{
|
||||
SetActive(true);
|
||||
|
||||
var success = false;
|
||||
|
||||
if (!WindowHaveIOpenAllowOpen && this is IYIUIOpen)
|
||||
{
|
||||
Debug.LogError($"当前View 有其他IOpen 接口 需要参数传入 不允许直接调用Open");
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
success = await OnOpen();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName={UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
await InternalOnWindowOpenTween();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
public async UniTask<bool> Open(ParamVo param)
|
||||
{
|
||||
if (WindowBanParamOpen)
|
||||
{
|
||||
Debug.LogError($"当前禁止使用ParamOpen 请检查");
|
||||
return false;
|
||||
}
|
||||
|
||||
SetActive(true);
|
||||
|
||||
var success = false;
|
||||
|
||||
try
|
||||
{
|
||||
success = await OnOpen(param);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName={UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
await InternalOnWindowOpenTween();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
public async UniTask<bool> Open<P1>(P1 p1)
|
||||
{
|
||||
SetActive(true);
|
||||
|
||||
var success = false;
|
||||
|
||||
if (this is IYIUIOpen<P1> view)
|
||||
{
|
||||
try
|
||||
{
|
||||
success = await view.OnOpen(p1);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName{UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return await UseBaseOpen();
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
await InternalOnWindowOpenTween();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
public async UniTask<bool> Open<P1, P2>(P1 p1, P2 p2)
|
||||
{
|
||||
SetActive(true);
|
||||
|
||||
var success = false;
|
||||
|
||||
if (this is IYIUIOpen<P1, P2> view)
|
||||
{
|
||||
try
|
||||
{
|
||||
success = await view.OnOpen(p1, p2);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName{UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return await UseBaseOpen();
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
await InternalOnWindowOpenTween();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
public async UniTask<bool> Open<P1, P2, P3>(P1 p1, P2 p2, P3 p3)
|
||||
{
|
||||
SetActive(true);
|
||||
|
||||
var success = false;
|
||||
|
||||
if (this is IYIUIOpen<P1, P2, P3> view)
|
||||
{
|
||||
try
|
||||
{
|
||||
success = await view.OnOpen(p1, p2, p3);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName{UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return await UseBaseOpen();
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
await InternalOnWindowOpenTween();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
public async UniTask<bool> Open<P1, P2, P3, P4>(P1 p1, P2 p2, P3 p3, P4 p4)
|
||||
{
|
||||
SetActive(true);
|
||||
|
||||
var success = false;
|
||||
|
||||
if (this is IYIUIOpen<P1, P2, P3, P4> view)
|
||||
{
|
||||
try
|
||||
{
|
||||
success = await view.OnOpen(p1, p2, p3, p4);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName{UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return await UseBaseOpen();
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
await InternalOnWindowOpenTween();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
public async UniTask<bool> Open<P1, P2, P3, P4, P5>(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
|
||||
{
|
||||
SetActive(true);
|
||||
|
||||
var success = false;
|
||||
|
||||
if (this is IYIUIOpen<P1, P2, P3, P4, P5> view)
|
||||
{
|
||||
try
|
||||
{
|
||||
success = await view.OnOpen(p1, p2, p3, p4, p5);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"ResName{UIResName}, err={e.Message}{e.StackTrace}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return await UseBaseOpen();
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
await InternalOnWindowOpenTween();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/View/BaseView_Open.cs.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/View/BaseView_Open.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 98d98381684a42899a63542d7d213fa6
|
||||
timeCreated: 1683797215
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Window.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Window.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4628a306f9ce4e65bb6f641d99fb7acf
|
||||
timeCreated: 1689323000
|
||||
15
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Window/BaseWindow.cs
vendored
Normal file
15
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Window/BaseWindow.cs
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
public abstract partial class BaseWindow : UIBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 窗口选项
|
||||
/// 最后由Panel View重写
|
||||
/// 实现各种配置
|
||||
/// 如非必要 所有属性判断可以直接去HasFlag分类中获取 不要直接判断这个
|
||||
/// </summary>
|
||||
public virtual EWindowOption WindowOption => EWindowOption.None;
|
||||
}
|
||||
}
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Window/BaseWindow.cs.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Window/BaseWindow.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f14db4037054efbb1e410c94f6f70e7
|
||||
timeCreated: 1683798125
|
||||
74
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Window/BaseWindow_Anim.cs
vendored
Normal file
74
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Window/BaseWindow_Anim.cs
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
//动画
|
||||
public abstract partial class BaseWindow
|
||||
{
|
||||
private bool m_FirstOpenTween;
|
||||
|
||||
internal async UniTask InternalOnWindowOpenTween(bool tween = true)
|
||||
{
|
||||
OnOpenTweenStart();
|
||||
|
||||
if (tween && !WindowBanRepetitionOpenTween || !m_FirstOpenTween)
|
||||
{
|
||||
m_FirstOpenTween = true;
|
||||
|
||||
if (WindowBanAwaitOpenTween)
|
||||
{
|
||||
SealedOnWindowOpenTween().Forget();
|
||||
}
|
||||
else
|
||||
{
|
||||
await SealedOnWindowOpenTween();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OnOpenTweenEnd();
|
||||
}
|
||||
}
|
||||
|
||||
private bool m_FirstCloseTween;
|
||||
|
||||
internal async UniTask InternalOnWindowCloseTween(bool tween = true)
|
||||
{
|
||||
OnCloseTweenStart();
|
||||
|
||||
if (tween && !WindowBanRepetitionCloseTween || !m_FirstCloseTween)
|
||||
{
|
||||
m_FirstCloseTween = true;
|
||||
|
||||
if (WindowBanAwaitCloseTween)
|
||||
{
|
||||
SealedOnWindowCloseTween().Forget();
|
||||
}
|
||||
else
|
||||
{
|
||||
await SealedOnWindowCloseTween();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OnCloseTweenEnd();
|
||||
}
|
||||
}
|
||||
|
||||
//由子类实现密封Async 调用End
|
||||
protected abstract UniTask SealedOnWindowOpenTween();
|
||||
|
||||
//任何UI可重写打开与关闭动画
|
||||
protected abstract UniTask OnOpenTween();
|
||||
|
||||
//有可能没有动画 也有可能动画被跳过 反正无论如何都会有动画结束回调
|
||||
protected abstract void OnOpenTweenStart();
|
||||
protected abstract void OnOpenTweenEnd();
|
||||
|
||||
protected abstract UniTask SealedOnWindowCloseTween();
|
||||
protected abstract UniTask OnCloseTween();
|
||||
|
||||
protected abstract void OnCloseTweenStart();
|
||||
protected abstract void OnCloseTweenEnd();
|
||||
}
|
||||
}
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Window/BaseWindow_Anim.cs.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Window/BaseWindow_Anim.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a2c237ed64024a4db33268ab930c344d
|
||||
timeCreated: 1689324285
|
||||
62
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Window/BaseWindow_HasFlag.cs
vendored
Normal file
62
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Window/BaseWindow_HasFlag.cs
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
namespace YIUIFramework
|
||||
{
|
||||
//窗口选项值 根据需求以下都可以重写 可动态改变值
|
||||
//所有窗口选项的属性
|
||||
//可快捷操作
|
||||
//亦可重写后根据需求动态调整
|
||||
public abstract partial class BaseWindow
|
||||
{
|
||||
/// <summary>
|
||||
/// 当打开的参数不一致时
|
||||
/// 是否可以使用基础Open
|
||||
/// 如果允许 别人调用open了一个不存在的Open参数时
|
||||
/// 也可以使用默认的open打开界面 则你可以改为true
|
||||
/// </summary>
|
||||
public virtual bool WindowCanUseBaseOpen => WindowOption.HasFlag(EWindowOption.CanUseBaseOpen);
|
||||
|
||||
/// <summary>
|
||||
/// 禁止使用ParamOpen
|
||||
/// </summary>
|
||||
public virtual bool WindowBanParamOpen => WindowOption.HasFlag(EWindowOption.BanParamOpen);
|
||||
|
||||
/// <summary>
|
||||
/// 我有其他IOpen时 允许用open
|
||||
/// 默认fasle 我有其他iopen接口时 是不允许使用open的
|
||||
/// </summary>
|
||||
public virtual bool WindowHaveIOpenAllowOpen => WindowOption.HasFlag(EWindowOption.HaveIOpenAllowOpen);
|
||||
|
||||
//先开
|
||||
public virtual bool WindowFirstOpen => WindowOption.HasFlag(EWindowOption.FirstOpen);
|
||||
|
||||
//后关
|
||||
public virtual bool WindowLastClose => WindowOption.HasFlag(EWindowOption.LastClose);
|
||||
|
||||
//禁止动画
|
||||
public virtual bool WindowBanTween => WindowOption.HasFlag(EWindowOption.BanTween);
|
||||
|
||||
//打开动画不可重复播放
|
||||
public virtual bool WindowBanRepetitionOpenTween => WindowOption.HasFlag(EWindowOption.BanRepetitionOpenTween);
|
||||
|
||||
//关闭动画不可重复播放
|
||||
public virtual bool WindowBanRepetitionCloseTween =>
|
||||
WindowOption.HasFlag(EWindowOption.BanRepetitionCloseTween);
|
||||
|
||||
//不等待打开动画
|
||||
public virtual bool WindowBanAwaitOpenTween => WindowOption.HasFlag(EWindowOption.BanAwaitOpenTween);
|
||||
|
||||
//不等待关闭动画
|
||||
public virtual bool WindowBanAwaitCloseTween => WindowOption.HasFlag(EWindowOption.BanAwaitCloseTween);
|
||||
|
||||
//我关闭时跳过其他的打开动画
|
||||
public virtual bool WindowSkipOtherOpenTween => WindowOption.HasFlag(EWindowOption.SkipOtherOpenTween);
|
||||
|
||||
//我打开时跳过其他的关闭动画
|
||||
public virtual bool WindowSkipOtherCloseTween => WindowOption.HasFlag(EWindowOption.SkipOtherCloseTween);
|
||||
|
||||
//Home时 跳过我自己的打开动画
|
||||
public virtual bool WindowSkipHomeOpenTween => WindowOption.HasFlag(EWindowOption.SkipHomeOpenTween);
|
||||
|
||||
//播放动画时 可以操作 默认播放动画的时候是不能操作UI的 不然容易出问题
|
||||
public virtual bool WindowAllowOptionByTween => WindowOption.HasFlag(EWindowOption.AllowOptionByTween);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70c82cb8ac4c4c218f74929ef32f8a8b
|
||||
timeCreated: 1689324378
|
||||
49
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Window/BaseWindow_OpenClose.cs
vendored
Normal file
49
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Panel/Base/Window/BaseWindow_OpenClose.cs
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
//打开关闭
|
||||
public abstract partial class BaseWindow
|
||||
{
|
||||
//打开有3种
|
||||
//1 无参打开 OnOpen
|
||||
//2 ParamVo参数打开 也叫 ParamOpen 打开内部是List<obj>参数 所以可以支持无限长度
|
||||
//3 继承接口IOpen的 也叫 IOpen 打开 最高支持5个泛型参数
|
||||
//前2种都会自带 第三种根据需求自己继承
|
||||
/// <summary>
|
||||
/// 打开UI 无参
|
||||
/// </summary>
|
||||
protected virtual async UniTask<bool> OnOpen()
|
||||
{
|
||||
await UniTask.CompletedTask;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开UI 带参数的
|
||||
/// 需要自己解析参数
|
||||
/// 适合用字符串开启的 参数可字符串配置那种
|
||||
/// 默认会调用onopen
|
||||
/// </summary>
|
||||
protected virtual async UniTask<bool> OnOpen(ParamVo param)
|
||||
{
|
||||
return await OnOpen();
|
||||
}
|
||||
|
||||
internal void OnWindowClose()
|
||||
{
|
||||
OnClose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// UI被关闭
|
||||
/// 与OnDisable 不同 Disable 只是显影操作不代表被关闭
|
||||
/// 与OnDestroy 不同 Destroy 是摧毁 但是因为有缓存界面的原因 当被缓存时 OnDestroy是不会来的
|
||||
/// 这个时候你想要知道是不是被关闭了就必须通过OnClose
|
||||
/// baseView除外 因为view的关闭就是隐藏 所以 view的 OnDisable = OnClose
|
||||
/// </summary>
|
||||
protected virtual void OnClose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8bd7dfdf2474fa2917685125f966d17
|
||||
timeCreated: 1689324334
|
||||
Reference in New Issue
Block a user