初始化

This commit is contained in:
come
2025-07-26 16:56:42 +08:00
parent 8291dbb91c
commit fa81439a8c
2574 changed files with 328492 additions and 2170 deletions

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f34e653c7b0c4a859aae3fc27afa8246
timeCreated: 1681899168

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2be05114d96a43e4ad0b490d9afa57ee
timeCreated: 1689323021

View 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
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 24d50b68ce6649a0a6610ea2a05b8716
timeCreated: 1681898395

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8a2f25bf5c5441178d8817ff3edb096f
timeCreated: 1689323009

View 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
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e0903f39d5074d8abc2d5e4f94faa5d2
timeCreated: 1683862460

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 77084063f9744ffc8a6f028970bcf901
timeCreated: 1689322970

View 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
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ef52b803bd61401897ae5642040cd9d6
timeCreated: 1681898370

View 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);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 74416b8f584e45b4a9c436d96b5cc35f
timeCreated: 1683889239

View 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();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 03365dc283b74259b6b1365f3507aa70
timeCreated: 1683886901

View 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;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8524a28809b546008658b643b82d5f8e
timeCreated: 1716112439

View 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
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f2af119f866046dc87febc299cdb2644
timeCreated: 1683799029

View 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;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d35290fb77ef4c6eb52caee150b65c39
timeCreated: 1683795537

View 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;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4b4ee8db93194df8b9c7988dca3701df
timeCreated: 1685587228

View File

@@ -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
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2dbb82e78ed84937b1757dc057ac2678
timeCreated: 1683809072

View File

@@ -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;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 62230f4010824c21b6295a2b6aa6277a
timeCreated: 1683881474

View 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();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 360f18fc00e744489e2e5a2d15f49951
timeCreated: 1685587311

View 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;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d92b104aba75473fae7b8724eb9b2a6d
timeCreated: 1683879762

View 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);
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b49f828695524bdf831f77cc731818c1
timeCreated: 1689325011

View 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);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9a45c498dabd405e9527697d9022de97
timeCreated: 1684145311

View 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 ?? "";
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: aac7aa8d5f1149a9a3125d82fc54920b
timeCreated: 1683878928

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7f9458c6e64841389a6a071d118af460
timeCreated: 1689322985

View 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
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8fce5356e45247d098a80b33ae50d355
timeCreated: 1681899010

View 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);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d10269ae02e548d393b7683b30b9d806
timeCreated: 1684119736

View 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();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5487f84a0fa4482dab277c0ee07f415c
timeCreated: 1684119708

View 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
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 98d98381684a42899a63542d7d213fa6
timeCreated: 1683797215

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4628a306f9ce4e65bb6f641d99fb7acf
timeCreated: 1689323000

View 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;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9f14db4037054efbb1e410c94f6f70e7
timeCreated: 1683798125

View 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();
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a2c237ed64024a4db33268ab930c344d
timeCreated: 1689324285

View 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);
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 70c82cb8ac4c4c218f74929ef32f8a8b
timeCreated: 1689324378

View 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()
{
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e8bd7dfdf2474fa2917685125f966d17
timeCreated: 1689324334

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: dad8caf5e8fd4c409e39aa002b11f0fe
timeCreated: 1682474419

View File

@@ -0,0 +1,34 @@
#if UNITY_EDITOR
using System.Text;
namespace YIUIFramework
{
/// <summary>
/// 用于EDITOR时使用Get取得数据列表
/// 编译时使用Get and GenCode来生成同类型代码
/// 然后使用新生成代码里的Get来得到数据列表
/// </summary>
/// <typeparam name="T"></typeparam>
public interface ICodeGenerator<T>
{
T[] Get();
/// <summary>
/// 生成数据代码仅能在editor里执行
/// 在方法里,只要写单项的属性设置代码就行了。
/// 而要设置的代码名默认叫"v";
/// </summary>
/// <param name="info"></param>
/// <param name="sb">用于写代码的SB</param>
/// <returns></returns>
void WriteCode(T info, StringBuilder sb);
/// <summary>
/// 可能遇到他是个单例不是new的情况 所以这里可以重写
/// </summary>
/// <param name="info"></param>
/// <param name="sb"></param>
void NewCode(T info, StringBuilder sb);
}
}
#endif

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d6a0dff0c78b4939a63cd8e0ea5fd36a
timeCreated: 1682072802

View File

@@ -0,0 +1,216 @@
//#define YIUIMACRO_SIMULATE_NONEEDITOR //模拟非编辑器状态 在编辑器使用 非编辑器加载模式 用于在编辑器下测试
using System;
using System.Collections.Generic;
using UnityEngine;
namespace YIUIFramework
{
/// <summary>
/// UI关联帮助类
/// </summary>
public static class UIBindHelper
{
/// <summary>
/// 根据创建时的类获取
/// </summary>
private static Dictionary<Type, UIBindVo> g_UITypeToPkgInfo = new Dictionary<Type, UIBindVo>();
/// <summary>
/// 根据 pkg + res 双字典获取
/// </summary>
private static Dictionary<string, Dictionary<string, UIBindVo>> g_UIPathToPkgInfo =
new Dictionary<string, Dictionary<string, UIBindVo>>();
/// <summary>
/// 只有panel 的信息
/// </summary>
private static Dictionary<string, UIBindVo> g_UIPanelNameToPkgInfo = new Dictionary<string, UIBindVo>();
//改为dll过后 提供给外部的方法
//1 从UI工具中自动生成绑定代码
//2 外部请直接调用此方法 UIBindHelper.InternalGameGetUIBindVoFunc = YIUICodeGenerated.UIBindProvider.Get;
public static Func<UIBindVo[]> InternalGameGetUIBindVoFunc { internal get; set; }
//初始化记录
public static bool IsInit { get; private set; }
public static Type BasePanelType = typeof(BasePanel);
/// <summary>
/// 初始化获取到所有UI相关的绑定关系
/// Editor下是反射
/// 其他 是序列化的文件 打包的时候一定要生成一次文件
/// </summary>
internal static bool InitAllBind()
{
if (IsInit)
{
Debug.LogError($"已经初始化过了 请检查");
return false;
}
#if !UNITY_EDITOR || YIUIMACRO_SIMULATE_NONEEDITOR
if (InternalGameGetUIBindVoFunc == null)
{
Debug.LogError($"使用非反射注册绑定 但是方法未实现 请检查");
return false;
}
var binds = InternalGameGetUIBindVoFunc?.Invoke();
#else
var binds = new UIBindProvider().Get();
#endif
if (binds == null || binds.Length <= 0)
{
Debug.LogError("没有找到绑定信息 或者 没有绑定信息 请检查");
return false;
}
g_UITypeToPkgInfo = new Dictionary<Type, UIBindVo>(binds.Length);
g_UIPathToPkgInfo = new Dictionary<string, Dictionary<string, UIBindVo>>();
g_UIPanelNameToPkgInfo = new Dictionary<string, UIBindVo>(binds.Length);
for (var i = 0; i < binds.Length; i++)
{
var vo = binds[i];
g_UITypeToPkgInfo[vo.CreatorType] = vo;
AddPkgInfoToPathDic(vo);
if (vo.CodeType == BasePanelType)
g_UIPanelNameToPkgInfo[vo.ResName] = vo;
}
IsInit = true;
return true;
}
private static void AddPkgInfoToPathDic(UIBindVo vo)
{
var pkgName = vo.PkgName;
var resName = vo.ResName;
if (!g_UIPathToPkgInfo.ContainsKey(pkgName))
{
g_UIPathToPkgInfo.Add(pkgName, new Dictionary<string, UIBindVo>());
}
var dic = g_UIPathToPkgInfo[pkgName];
if (dic.ContainsKey(resName))
{
Debug.LogError($"重复资源 请检查 {pkgName} {resName}");
return;
}
dic.Add(resName, vo);
}
/// <summary>
/// 得到UI包信息
/// </summary>
/// <param name="uiType"></param>
/// <returns></returns>
public static UIBindVo? GetBindVoByType(Type uiType)
{
if (uiType == null)
{
Debug.LogError($"空 无法取到这个包信息 请检查");
return null;
}
if (g_UITypeToPkgInfo.TryGetValue(uiType, out var vo))
{
return vo;
}
Debug.LogError($"未获取到这个UI包信息 请检查 {uiType.Name}");
return null;
}
/// <summary>
/// 得到UI包信息
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static UIBindVo? GetBindVoByType<T>()
{
return GetBindVoByType(typeof(T));
}
/// <summary>
/// 根据唯一ID获取
/// 由pkg+res 拼接的唯一ID
/// </summary>
public static UIBindVo? GetBindVoByPath(string pkgName, string resName)
{
if (string.IsNullOrEmpty(pkgName) || string.IsNullOrEmpty(resName))
{
Debug.LogError($"空名称 无法取到这个包信息 请检查");
return null;
}
if (!g_UIPathToPkgInfo.ContainsKey(pkgName))
{
Debug.LogError($"不存在这个包信息 请检查 {pkgName}");
return null;
}
if (g_UIPathToPkgInfo[pkgName].TryGetValue(resName, out var vo))
{
return vo;
}
Debug.LogError($"未获取到这个包信息 请检查 {pkgName} {resName}");
return null;
}
/// <summary>
/// 根据panelName获取
/// 只有是panel才会存在的信息
/// 非Panel请使用其他
/// </summary>
internal static UIBindVo? GetBindVoByPanelName(string panelName)
{
if (string.IsNullOrEmpty(panelName))
{
Debug.LogError($"空名称 无法取到这个包信息 请检查");
return null;
}
if (g_UIPanelNameToPkgInfo.TryGetValue(panelName, out var vo))
{
return vo;
}
Debug.LogError($"未获取到这个包信息 请检查 {panelName}");
return null;
}
/// <summary>
/// 重置 慎用
/// </summary>
public static void Reset()
{
if (g_UITypeToPkgInfo != null)
{
g_UITypeToPkgInfo.Clear();
g_UITypeToPkgInfo = null;
}
if (g_UIPathToPkgInfo != null)
{
g_UIPathToPkgInfo.Clear();
g_UIPathToPkgInfo = null;
}
if (g_UIPanelNameToPkgInfo != null)
{
g_UIPanelNameToPkgInfo.Clear();
g_UIPanelNameToPkgInfo = null;
}
IsInit = false;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d09de6223df6425081b47e22385f3747
timeCreated: 1682217977

View File

@@ -0,0 +1,151 @@
#if UNITY_EDITOR
using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
namespace YIUIFramework
{
internal class UIBindProvider : ICodeGenerator<UIBindVo>
{
//业务代码相关程序集的名字
//默认有Unity默认程序集 可以根据需求修改
internal static string[] LogicAssemblyNames = { "Assembly-CSharp" };
private static Type[] GetLogicTypes()
{
return AppDomain.CurrentDomain.GetTypesByAssemblyName(LogicAssemblyNames);
}
private Type m_BasePanelType = typeof(BasePanel);
private Type m_BaseViewType = typeof(BaseView);
private Type m_BaseComponentType = typeof(BaseComponent);
public UIBindVo[] Get()
{
var gameTypes = GetLogicTypes();
if (gameTypes.Length < 1)
{
return Array.Empty<UIBindVo>();
}
var panelTypes = new List<Type>(); //继承panel的
var viewTypes = new List<Type>(); //继承View的
var componentTypes = new List<Type>(); //继承Component的
var binds = new List<UIBindVo>();
foreach (var gameType in gameTypes)
{
if (m_BasePanelType.IsAssignableFrom(gameType))
{
panelTypes.Add(gameType);
}
else if (m_BaseViewType.IsAssignableFrom(gameType))
{
viewTypes.Add(gameType);
}
else if (m_BaseComponentType.IsAssignableFrom(gameType))
{
componentTypes.Add(gameType);
}
}
//panel绑定
foreach (var panelType in panelTypes)
{
if (panelType.BaseType == null)
{
continue;
}
if (GetBindVo(panelType.BaseType, panelType, m_BasePanelType, out var bindVo))
{
binds.Add(bindVo);
}
}
//view绑定
foreach (var viewType in viewTypes)
{
if (viewType.BaseType == null)
{
continue;
}
if (GetBindVo(viewType.BaseType, viewType, m_BaseViewType, out var bindVo))
{
binds.Add(bindVo);
}
}
//component绑定
foreach (var componentType in componentTypes)
{
if (componentType.BaseType == null)
{
continue;
}
if (GetBindVo(componentType.BaseType, componentType, m_BaseComponentType, out var bindVo))
{
binds.Add(bindVo);
}
}
return binds.ToArray();
}
private static bool GetBindVo(Type uiBaseType, Type creatorType, Type groupType, out UIBindVo bindVo)
{
bindVo = new UIBindVo();
if (uiBaseType == null ||
!uiBaseType.GetFieldValue("PkgName", out bindVo.PkgName) ||
!uiBaseType.GetFieldValue("ResName", out bindVo.ResName))
{
return false;
}
bindVo.CodeType = uiBaseType.BaseType;
bindVo.BaseType = uiBaseType;
bindVo.CreatorType = creatorType;
return true;
}
public void WriteCode(UIBindVo info, StringBuilder sb)
{
sb.Append(" {\r\n");
sb.AppendFormat(" PkgName = {0}.PkgName,\r\n", info.BaseType.FullName);
sb.AppendFormat(" ResName = {0}.ResName,\r\n", info.BaseType.FullName);
sb.AppendFormat(" CodeType = {0},\r\n", GetCodeTypeName(info.CodeType));
sb.AppendFormat(" BaseType = typeof({0}),\r\n", info.BaseType.FullName);
sb.AppendFormat(" CreatorType = typeof({0}),\r\n", info.CreatorType.FullName);
sb.Append(" };\r\n");
}
private string GetCodeTypeName(Type uiBaseType)
{
if (uiBaseType == m_BasePanelType)
{
return UIStaticHelper.UIBasePanelName;
}
else if (uiBaseType == m_BaseViewType)
{
return UIStaticHelper.UIBaseViewName;
}
else if (uiBaseType == m_BaseComponentType)
{
return UIStaticHelper.UIBaseComponentName;
}
else
{
Debug.LogError($"当前类型错误 是否新增了类型 {uiBaseType}");
return UIStaticHelper.UIBaseName;
}
}
public void NewCode(UIBindVo info, StringBuilder sb)
{
}
}
}
#endif

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4e96ffe5c3d54fef915c3a7845173cb1
timeCreated: 1682218117

View File

@@ -0,0 +1,25 @@
using System;
namespace YIUIFramework
{
/// <summary>
/// UI资源绑定信息
/// </summary>
public struct UIBindVo
{
//基类
public Type CodeType; //Panel/View/Component
//当前继承类
public Type BaseType; //他继承的类 就是 当前 + Base
//当前类
public Type CreatorType;
//包名/模块名
public string PkgName;
//资源名
public string ResName;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4e6d04d42ac04fcd8433e8eeaeb75889
timeCreated: 1682218000

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: af93bc2020e44d85a4c9353fc1a60f80
timeCreated: 1681898432

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 13b1b428c583478b88e85cff6663d5dc
timeCreated: 1681899208

View File

@@ -0,0 +1,75 @@
using Sirenix.OdinInspector;
namespace YIUIFramework
{
//不要修改值 否则已存在的界面会错误
//只能新增 不允许修改
/// <summary>
/// 层级类型
/// </summary>
[LabelText("层级类型")]
public enum EPanelLayer
{
/// <summary>
/// 最高层
/// 一般新手引导之类的
/// </summary>
[LabelText("最高层")]
Top = 0,
/// <summary>
/// 提示层
/// 一般 提示飘字 确认弹窗 跑马灯之类的
/// </summary>
[LabelText("提示层")]
Tips = 1,
/// <summary>
/// 弹窗层
/// 一般是非全屏界面,可同时存在的
/// </summary>
[LabelText("弹窗层")]
Popup = 2,
/// <summary>
/// 普通面板层
/// 全屏界面 所有Panel打开关闭受回退功能影响
/// </summary>
[LabelText("面板层")]
Panel = 3,
/// <summary>
/// 场景层
/// 比如 血条飘字不是做在3D时 用2D实现时的层
/// 比如 头像 ...
/// </summary>
[LabelText("场景层")]
Scene = 4,
/// <summary>
/// 最低层
/// 要显示的这个就是最低的层级
/// </summary>
[LabelText("最低层")]
Bottom = 5,
/// <summary>
/// 缓存层 需要缓存的暂存的丢这里
/// 这个界面不做显示 会被强制隐藏的
/// </summary>
[LabelText("")]
Cache = 6,
/// <summary>
/// 只是用来记录数量,不可用
/// </summary>
[LabelText("")]
Count = 7,
/// <summary>
/// 所有层,不可用
/// </summary>
[LabelText("")]
Any = 8,
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3cd50e5bf988429898fcc02e31f2770f
timeCreated: 1681899230

View File

@@ -0,0 +1,43 @@
using System;
using Sirenix.OdinInspector;
namespace YIUIFramework
{
//不要修改值 否则已存在的界面会错误
//只能新增 不允许修改
[LabelText("界面选项")]
[Flags]
public enum EPanelOption
{
[LabelText("无")]
None = 0,
[LabelText("容器类界面")]
Container = 1, //比如伤害飘字 此类界面如果做到panel层会被特殊处理 建议还是不要放到panel层
[LabelText("永久缓存界面")]
ForeverCache = 1 << 1, //永远不会被摧毁 与禁止关闭不同这个可以关闭 只是不销毁 也可相当于无限长的倒计时
[LabelText("倒计时缓存界面")]
TimeCache = 1 << 2, //被关闭后X秒之后在摧毁 否则理解摧毁
[LabelText("禁止关闭的界面")]
DisClose = 1 << 3, //是需要一直存在的你可以隐藏 但是你不能摧毁
[LabelText("忽略返回 返回操作会跳过这个界面")]
IgnoreBack = 1 << 4, //他的打开与关闭不会触发返回功能 堆栈功能
}
public static class PanelOptionExt
{
public static void Set(ref this EPanelOption owner, EPanelOption option)
{
owner |= option;
}
public static void Unset(ref this EPanelOption owner, EPanelOption option)
{
owner &= (~option);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: cf78d918fc24422d9300f7508a6b9feb
timeCreated: 1681898532

View File

@@ -0,0 +1,25 @@
using Sirenix.OdinInspector;
namespace YIUIFramework
{
//不要修改值 否则已存在的界面会错误
//只能新增 不允许修改
/// <summary>
/// Panel堆栈操作
/// </summary>
[LabelText("堆栈操作")]
public enum EPanelStackOption
{
[LabelText("不操作 就叠加管理")]
None = 0,
[LabelText("显隐 不会触发动画")]
Visible = 1,
[LabelText("显隐 会触发动画")]
VisibleTween = 2, //堆栈逻辑中没有关闭逻辑都是隐藏 一个会触发动画一个不会 这个会触发关闭动画
[LabelText("省略 忽略 排除")]
Omit = 3, //当他打开其他界面时 自己会被关闭 且不进入堆栈 自己被关闭时 会触发堆栈
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a29970e8ab1145419ce0d9d7e630fc65
timeCreated: 1681899358

View File

@@ -0,0 +1,22 @@
using Sirenix.OdinInspector;
namespace YIUIFramework
{
//不要修改值 否则已存在的界面会错误
//只能新增 不允许修改
/// <summary>
/// View堆栈操作
/// </summary>
[LabelText("堆栈操作")]
public enum EViewStackOption
{
[LabelText("不操作 就叠加管理")]
None = 0,
[LabelText("显隐 不触发动画")]
Visible = 1, //直接显影
[LabelText("显隐 会触发动画")]
VisibleTween = 2, //堆栈逻辑中没有关闭逻辑都是隐藏 一个会触发动画一个不会 这个会触发关闭动画
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 50190b79766b448fa10788008b2c7ee1
timeCreated: 1683886374

View File

@@ -0,0 +1,16 @@
using Sirenix.OdinInspector;
namespace YIUIFramework
{
//不要修改值 否则已存在的界面会错误
//只能新增 不允许修改
[LabelText("层级类型")]
public enum EViewWindowType
{
[LabelText("窗口")]
View = 0,
[LabelText("弹窗")]
Popup = 1,
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 50c1d3f3ceaf45e4bbb2a67023008273
timeCreated: 1683887706

View File

@@ -0,0 +1,74 @@
using System;
using Sirenix.OdinInspector;
namespace YIUIFramework
{
//不要修改值 否则已存在的界面会错误
//只能新增 不允许修改
[LabelText("窗口选项")]
[Flags]
public enum EWindowOption
{
[LabelText("无")]
None = 0,
/// 当打开的参数不一致时
/// 是否可以使用基础Open
/// 如果允许 别人调用open了一个不存在的Open参数时
/// 也可以使用默认的open打开界面 则你可以改为true
[LabelText("参数不一致时 可以使用基础Open")]
CanUseBaseOpen = 1,
[LabelText("禁止使用ParamOpen")]
BanParamOpen = 1 << 1, //paramOpen 是obj参数形式的Open
[LabelText("我有其他IOpen时 允许用open")]
HaveIOpenAllowOpen = 1 << 2, //默认情况下如果你有IOpen接口 就必须强制使用这个接口打开
[LabelText("先开")]
FirstOpen = 1 << 3, // 默认后开 (如果先开: 当前UI先播放动画然后关闭其他UI 否则 其他UI先关闭 当前UI后打开)
[LabelText("后关")]
LastClose = 1 << 4, // 默认先关 (自己再打开其他 如果后关: 先打开其他 再关闭自己 这个时候大概率是看不到自己的关闭动画的)
[LabelText("禁止动画")]
BanTween = 1 << 10, //所有开关动画都会被跳过
[LabelText("打开动画不可重复播放")]
BanRepetitionOpenTween = 1 << 11, //生命周期内 打开动画只可以播放一次
[LabelText("关闭动画不可重复播放")]
BanRepetitionCloseTween = 1 << 12, //生命周期内 关闭动画只可以播放一次
[LabelText("不等待打开动画")]
BanAwaitOpenTween = 1 << 13, //这个影响的是打开动画之后的回调时机
[LabelText("不等待关闭动画")]
BanAwaitCloseTween = 1 << 14, //要动画完毕过后才会收到close回调 如果跳过就会立马收到
[LabelText("我关闭时跳过其他的打开动画")]
SkipOtherOpenTween = 1 << 15, //我关闭时 其他的界面直接打开不需要播放动画
[LabelText("我打开时跳过其他的关闭动画")]
SkipOtherCloseTween = 1 << 16, //我打开时 其他的界面直接关闭不需要播放动画
[LabelText("Home时 跳过我自己的打开动画")]
SkipHomeOpenTween = 1 << 17, //被Home的界面直接打开 不播放动画
[LabelText("播放动画时 可以操作")]
AllowOptionByTween = 1 << 18, //默认播放动画的时候是不能操作UI的 不然容易出问题
}
public static class WindowOptionOptionExt
{
public static void Set(ref this EWindowOption owner, EWindowOption option)
{
owner |= option;
}
public static void Unset(ref this EWindowOption owner, EWindowOption option)
{
owner &= (~option);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2582d3c00b6e47a683d7b4ef29245d7c
timeCreated: 1688635736

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: aaca2eaea675486986f13eff3f27d791
timeCreated: 1688739194

View File

@@ -0,0 +1,31 @@
namespace YIUIFramework
{
/// <summary>
/// 触发堆栈时 会有消息
/// 参数info 是给你看触发你消息的是谁
/// 不要滥用 不要修改里面的值
/// </summary>
public interface IYIUIBack
{
/// <summary>
/// 是被关闭触发 (有界面打开 当前界面被关闭)
/// 自己被关闭
/// </summary>
/// <param name="info">触发的那个界面是谁</param>
void DoBackClose(PanelInfo info);
/// <summary>
/// 是添加触发 (有其他界面关闭 当前界面被打开)
/// 自己被打开
/// </summary>
/// <param name="info">触发的那个界面是谁</param>
void DoBackAdd(PanelInfo info);
/// <summary>
/// Home触发 (有其他界面打开 当前界面被关闭)
/// 自己被关闭
/// </summary>
/// <param name="info">触发的那个界面是谁</param>
void DoBackHome(PanelInfo info);
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4e4b1cd88ceb42f5836b39219b6bdfd8
timeCreated: 1688726015

View File

@@ -0,0 +1,13 @@
namespace YIUIFramework
{
/// <summary>
/// 当一个界面 EPanelOption.DisClose 时 (禁止关闭)
/// 且又被调用时 则会触发 可根据需求继承
/// </summary>
public interface IYIUIBanClose
{
//根据需求返回 是否可以被关闭
//返回true 就是可以被关闭
bool DoBanClose();
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1f3784419e6143cd85a59a9fcc193030
timeCreated: 1688726154

View File

@@ -0,0 +1,33 @@
using Cysharp.Threading.Tasks;
namespace YIUIFramework
{
public interface IYIUIOpen
{
}
public interface IYIUIOpen<P1> : IYIUIOpen
{
UniTask<bool> OnOpen(P1 p1);
}
public interface IYIUIOpen<P1, P2> : IYIUIOpen
{
UniTask<bool> OnOpen(P1 p1, P2 p2);
}
public interface IYIUIOpen<P1, P2, P3> : IYIUIOpen
{
UniTask<bool> OnOpen(P1 p1, P2 p2, P3 p3);
}
public interface IYIUIOpen<P1, P2, P3, P4> : IYIUIOpen
{
UniTask<bool> OnOpen(P1 p1, P2 p2, P3 p3, P4 p4);
}
public interface IYIUIOpen<P1, P2, P3, P4, P5> : IYIUIOpen
{
UniTask<bool> OnOpen(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5);
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0b168301c2b845a18caebfaa2746939b
timeCreated: 1681898440

View File

@@ -0,0 +1,28 @@
namespace YIUIFramework
{
/// <summary>
/// 面板接口
/// </summary>
public interface IYIUIPanel : IYIUIWindow
{
/// <summary>
/// 得到窗口所在的层
/// </summary>
EPanelLayer Layer { get; }
/// <summary>
/// 界面的各种选项
/// </summary>
EPanelOption PanelOption { get; }
/// <summary>
/// 面板堆栈操作
/// </summary>
EPanelStackOption StackOption { get; }
/// <summary>
/// 同层级,优先级高的在前面
/// </summary>
int Priority { get; }
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 389937c9848548199e2083daa3b39e33
timeCreated: 1681898436

View File

@@ -0,0 +1,9 @@
namespace YIUIFramework
{
/// <summary>
/// View接口
/// </summary>
public interface IYIUIView : IYIUIWindow
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b5f2f5ec1c684aac92f7f589dedd2af1
timeCreated: 1683797315

View File

@@ -0,0 +1,30 @@
using Cysharp.Threading.Tasks;
namespace YIUIFramework
{
public interface IYIUIWindow
{
UniTask<bool> Open();
UniTask<bool> Open(ParamVo param);
UniTask<bool> Open<P1>(P1 p1);
UniTask<bool> Open<P1, P2>(P1 p1, P2 p2);
UniTask<bool> Open<P1, P2, P3>(P1 p1, P2 p2, P3 p3);
UniTask<bool> Open<P1, P2, P3, P4>(P1 p1, P2 p2, P3 p3, P4 p4);
UniTask<bool> Open<P1, P2, P3, P4, P5>(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5);
/// <summary>
/// 窗口选项
/// </summary>
EWindowOption WindowOption { get; }
/// <summary>
/// 显隐状态
/// </summary>
bool ActiveSelf { get; }
/// <summary>
/// 关闭窗口
/// </summary>
void Close(bool tween = true, bool ignoreElse = false);
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 283b0c644f704d97a19f280853cbb1e4
timeCreated: 1684130734

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: dc40a5290dcc4e649dcbb4b4a46fc341
timeCreated: 1689323199

View File

@@ -0,0 +1,40 @@
using Cysharp.Threading.Tasks;
using DG.Tweening;
using UnityEngine;
namespace YIUIFramework
{
/// <summary>
/// 简单的窗口动画
/// </summary>
public static class WindowFadeAnim
{
private static Vector3 m_AnimScale = new Vector3(0.8f, 0.8f, 0.8f);
//淡入
public static async UniTask In(UIBase uiBase, float time = 0.25f)
{
var obj = uiBase?.OwnerGameObject;
if (obj == null) return;
uiBase.SetActive(true);
obj.transform.localScale = m_AnimScale;
await obj.transform.DOScale(Vector3.one, time);
}
//淡出
public static async UniTask Out(UIBase uiBase, float time = 0.25f)
{
var obj = uiBase?.OwnerGameObject;
if (obj == null) return;
obj.transform.localScale = Vector3.one;
await obj.transform.DOScale(m_AnimScale, time);
uiBase.SetActive(false);
obj.transform.localScale = Vector3.one;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0cb517a7f20e40aa9f4803d50395e1c0
timeCreated: 1684120651

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: fa0e99e0a8094fc4bc2afd6b9a75a347
timeCreated: 1682496719

View File

@@ -0,0 +1,45 @@
using UnityEngine;
namespace YIUIFramework
{
/// <summary>
/// 面板信息
/// </summary>
public class PanelInfo
{
public BasePanel UIBasePanel { get; private set; }
public bool ActiveSelf => UIBasePanel?.ActiveSelf ?? false;
/// <summary>
/// 包名
/// </summary>
public string PkgName { get; internal set; }
/// <summary>
/// 资源名称 因为每个包分开 这个资源名称是有可能重复的 虽然设计上不允许
/// </summary>
public string ResName { get; internal set; }
/// <summary>
/// C#文件名 因为有可能存在Res名称与文件名不一致的问题
/// </summary>
public string Name { get; internal set; }
internal void Reset(UIBase uiBase)
{
switch (uiBase)
{
case null:
UIBasePanel = null;
break;
case BasePanel basePanel:
UIBasePanel = basePanel;
break;
default:
Debug.LogError($"当前UI 不是Panel 请检查 {PkgName} {ResName}");
break;
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6cd37b35cb984ee480cbca8c59547621
timeCreated: 1681898498

View File

@@ -0,0 +1,34 @@
using System.Collections.Generic;
using Cysharp.Threading.Tasks;
using UnityEngine;
namespace YIUIFramework
{
/// <summary>
/// YIUI 面板管理器
/// </summary>
public partial class PanelMgr : MgrSingleton<PanelMgr>
{
//低品质 将会影响动画等逻辑 也可以根据这个参数自定义一些区别
public static bool IsLowQuality = false;
//绑定初始化情况
public static bool BindInit { private set; get; }
protected override async UniTask<bool> MgrAsyncInit()
{
BindInit = UIBindHelper.InitAllBind();
if (!await InitRoot()) return false;
InitSafeArea();
return true;
}
protected override void OnDispose()
{
ResetRoot();
OnBlockDispose();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b786e4b603514a25963ba5537c7416ea
timeCreated: 1681898783

View File

@@ -0,0 +1,69 @@
namespace YIUIFramework
{
public partial class PanelMgr
{
#region Panel是否存在且显示
public bool ActiveSelf(string panelName)
{
var info = GetPanelInfo(panelName);
return info?.ActiveSelf ?? false;
}
public bool ActiveSelf<T>() where T : BasePanel
{
var info = GetPanelInfo<T>();
return info?.ActiveSelf ?? false;
}
#endregion
#region Panel的指定View是否存在且显示
public bool ActiveSelfView(string panelName, string viewName)
{
var info = GetPanelInfo(panelName);
if (info == null) return false;
if (info.UIBasePanel == null) return false;
var (exist, entity) = info.UIBasePanel.ExistView(viewName);
if (!exist) return false;
return entity.ActiveSelf;
}
public bool ActiveSelfView<TPanel, TView>()
where TPanel : BasePanel
where TView : BaseView
{
var info = GetPanelInfo<TPanel>();
if (info == null) return false;
if (info.UIBasePanel == null) return false;
var (exist, entity) = info.UIBasePanel.ExistView<TView>();
if (!exist) return false;
return entity.ActiveSelf;
}
public bool ActiveSelfViewByViewName<TPanel>(string viewName)
where TPanel : BasePanel
{
var info = GetPanelInfo<TPanel>();
if (info == null) return false;
if (info.UIBasePanel == null) return false;
var (exist, entity) = info.UIBasePanel.ExistView(viewName);
if (!exist) return false;
return entity.ActiveSelf;
}
public bool ActiveSelfViewByPanelName<TView>(string panelName)
where TView : BaseView
{
var info = GetPanelInfo(panelName);
if (info == null) return false;
if (info.UIBasePanel == null) return false;
var (exist, entity) = info.UIBasePanel.ExistView<TView>();
if (!exist) return false;
return entity.ActiveSelf;
}
#endregion
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c95d90afbff74d2ebffe4411639427ea
timeCreated: 1684120713

Some files were not shown because too many files have changed in this diff Show More