初始化
This commit is contained in:
17
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/EUICodeType.cs
vendored
Normal file
17
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/EUICodeType.cs
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
using Sirenix.OdinInspector;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
[LabelText("组件类型")]
|
||||
public enum EUICodeType
|
||||
{
|
||||
[LabelText("Panel 面板")]
|
||||
Panel,
|
||||
|
||||
[LabelText("View 界面")]
|
||||
View,
|
||||
|
||||
[LabelText("Component 组件")]
|
||||
Component,
|
||||
}
|
||||
}
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/EUICodeType.cs.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/EUICodeType.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e337ad83123e4e5bba290b61e07903ad
|
||||
timeCreated: 1682427307
|
||||
102
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIBindCDETable.cs
vendored
Normal file
102
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIBindCDETable.cs
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
//------------------------------------------------------------
|
||||
// Author: 亦亦
|
||||
// Mail: 379338943@qq.com
|
||||
// Data: 2023年2月12日
|
||||
//------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.Serialization;
|
||||
using YIUIBind;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
//[DetailedInfoBox("UI CDE总表 点击展开详细介绍", @"李胜扬")]
|
||||
[Serializable]
|
||||
[LabelText("UI CDE总表")]
|
||||
[AddComponentMenu("YIUIBind/★★★★★UI CDE Table 总表★★★★★")]
|
||||
public sealed partial class UIBindCDETable : SerializedMonoBehaviour
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
[InlineButton("AddComponentTable", "Add")]
|
||||
[EnableIf("@UIOperationHelper.CommonShowIf()")]
|
||||
#endif
|
||||
public UIBindComponentTable ComponentTable;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[InlineButton("AddDataTable", "Add")]
|
||||
[EnableIf("@UIOperationHelper.CommonShowIf()")]
|
||||
#endif
|
||||
public UIBindDataTable DataTable;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[InlineButton("AddEventTable", "Add")]
|
||||
[EnableIf("@UIOperationHelper.CommonShowIf()")]
|
||||
#endif
|
||||
public UIBindEventTable EventTable;
|
||||
|
||||
[LabelText("UI包名")]
|
||||
[ReadOnly]
|
||||
public string PkgName;
|
||||
|
||||
[LabelText("UI资源名")]
|
||||
[ReadOnly]
|
||||
public string ResName;
|
||||
|
||||
#region 关联
|
||||
|
||||
//关联的UI
|
||||
private UIBase m_UIBase;
|
||||
|
||||
[OdinSerialize]
|
||||
[LabelText("编辑时所有公共组件")]
|
||||
[ReadOnly]
|
||||
[PropertyOrder(1000)] //生成UI类时使用
|
||||
#if UNITY_EDITOR
|
||||
[ShowIf("@UIOperationHelper.CommonShowIf()")]
|
||||
#endif
|
||||
internal List<UIBindCDETable> AllChildCdeTable = new List<UIBindCDETable>();
|
||||
|
||||
[OdinSerialize]
|
||||
[NonSerialized]
|
||||
[ShowInInspector]
|
||||
[ReadOnly]
|
||||
[PropertyOrder(1000)]
|
||||
[LabelText("运行时所有公共组件")] //动态生成后的子类(公共组件) 运行时使用
|
||||
#if UNITY_EDITOR
|
||||
[HideIf("@UIOperationHelper.CommonShowIf()")]
|
||||
#endif
|
||||
private Dictionary<string, UIBase> m_AllChildUIBase = new Dictionary<string, UIBase>();
|
||||
|
||||
internal void AddUIBase(string uiName, UIBase uiBase)
|
||||
{
|
||||
if (m_AllChildUIBase.ContainsKey(uiName))
|
||||
{
|
||||
Debug.LogError($"{name} 已存在 {uiName} 请检查为何重复添加 是否存在同名组件");
|
||||
return;
|
||||
}
|
||||
|
||||
m_AllChildUIBase.Add(uiName, uiBase);
|
||||
}
|
||||
|
||||
internal UIBase FindUIBase(string uiName)
|
||||
{
|
||||
if (!m_AllChildUIBase.ContainsKey(uiName))
|
||||
{
|
||||
Debug.LogError($"{name} 不存在 {uiName} 请检查");
|
||||
return null;
|
||||
}
|
||||
|
||||
return m_AllChildUIBase[uiName];
|
||||
}
|
||||
|
||||
public T FindUIBase<T>(string uiName) where T : UIBase
|
||||
{
|
||||
return (T)FindUIBase(uiName);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIBindCDETable.cs.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIBindCDETable.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 76af6b314c984a70bd77fd9c0d998f89
|
||||
timeCreated: 1681228108
|
||||
328
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIBindCDETable_Editor.cs
vendored
Normal file
328
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIBindCDETable_Editor.cs
vendored
Normal file
@@ -0,0 +1,328 @@
|
||||
#if UNITY_EDITOR
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using Sirenix.OdinInspector;
|
||||
using YIUIBind;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using YIUIFramework.Editor;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
//Editor
|
||||
public sealed partial class UIBindCDETable
|
||||
{
|
||||
#region 界面参数
|
||||
|
||||
[LabelText("组件类型")]
|
||||
[OnValueChanged("OnValueChangedEUICodeType")]
|
||||
[ReadOnly]
|
||||
public EUICodeType UICodeType = EUICodeType.Component;
|
||||
|
||||
[BoxGroup("配置", true, true)]
|
||||
[HideIf("UICodeType", EUICodeType.Component)]
|
||||
[LabelText("窗口选项")]
|
||||
[GUIColor(0, 1, 1)]
|
||||
[EnableIf("@UIOperationHelper.CommonShowIf()")]
|
||||
public EWindowOption WindowOption = EWindowOption.None;
|
||||
|
||||
[ShowIf("UICodeType", EUICodeType.Panel)]
|
||||
[BoxGroup("配置", true, true)]
|
||||
[OnValueChanged("OnValueChangedEPanelLayer")]
|
||||
[GUIColor(0, 1, 1)]
|
||||
[EnableIf("@UIOperationHelper.CommonShowIf()")]
|
||||
public EPanelLayer PanelLayer = EPanelLayer.Panel;
|
||||
|
||||
[ShowIf("UICodeType", EUICodeType.Panel)]
|
||||
[BoxGroup("配置", true, true)]
|
||||
[GUIColor(0, 1, 1)]
|
||||
[EnableIf("@UIOperationHelper.CommonShowIf()")]
|
||||
public EPanelOption PanelOption = EPanelOption.None;
|
||||
|
||||
[ShowIf("UICodeType", EUICodeType.Panel)]
|
||||
[BoxGroup("配置", true, true)]
|
||||
[GUIColor(0, 1, 1)]
|
||||
[EnableIf("@UIOperationHelper.CommonShowIf()")]
|
||||
public EPanelStackOption PanelStackOption = EPanelStackOption.VisibleTween;
|
||||
|
||||
[ShowIf("UICodeType", EUICodeType.View)]
|
||||
[BoxGroup("配置", true, true)]
|
||||
[GUIColor(0, 1, 1)]
|
||||
[EnableIf("@UIOperationHelper.CommonShowIf()")]
|
||||
public EViewWindowType ViewWindowType = EViewWindowType.View;
|
||||
|
||||
[ShowIf("UICodeType", EUICodeType.View)]
|
||||
[BoxGroup("配置", true, true)]
|
||||
[GUIColor(0, 1, 1)]
|
||||
[EnableIf("@UIOperationHelper.CommonShowIf()")]
|
||||
public EViewStackOption ViewStackOption = EViewStackOption.VisibleTween;
|
||||
|
||||
[ShowIf("ShowCachePanelTime", EUICodeType.Panel)]
|
||||
[BoxGroup("配置", true, true)]
|
||||
[GUIColor(0, 1, 1)]
|
||||
[LabelText("缓存时间")]
|
||||
[EnableIf("@UIOperationHelper.CommonShowIf()")]
|
||||
public float CachePanelTime = 10;
|
||||
|
||||
private bool ShowCachePanelTime => PanelOption.HasFlag(EPanelOption.TimeCache);
|
||||
|
||||
[LabelText("同层级时 优先级高的在前面")] //相同时后开的在前
|
||||
[ShowIf("UICodeType", EUICodeType.Panel)]
|
||||
[BoxGroup("配置", true, true)]
|
||||
[GUIColor(0, 1, 1)]
|
||||
[EnableIf("@UIOperationHelper.CommonShowIf()")]
|
||||
public int Priority = 0;
|
||||
|
||||
private void OnValueChangedEUICodeType()
|
||||
{
|
||||
if (name.EndsWith(UIStaticHelper.UIPanelName) || name.EndsWith(UIStaticHelper.UIPanelSourceName))
|
||||
{
|
||||
if (UICodeType != EUICodeType.Panel)
|
||||
{
|
||||
Debug.LogWarning($"{name} 结尾{UIStaticHelper.UIPanelName} 必须设定为{UIStaticHelper.UIPanelName}类型");
|
||||
}
|
||||
|
||||
UICodeType = EUICodeType.Panel;
|
||||
}
|
||||
else if (name.EndsWith(UIStaticHelper.UIViewName))
|
||||
{
|
||||
if (UICodeType != EUICodeType.View)
|
||||
{
|
||||
Debug.LogWarning($"{name} 结尾{UIStaticHelper.UIViewName} 必须设定为{UIStaticHelper.UIViewName}类型");
|
||||
}
|
||||
|
||||
UICodeType = EUICodeType.View;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (UICodeType != EUICodeType.Component)
|
||||
{
|
||||
Debug.LogWarning($"{name} 想设定为其他类型 请按照规则设定 请勿强行修改");
|
||||
}
|
||||
|
||||
UICodeType = EUICodeType.Component;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnValueChangedEPanelLayer()
|
||||
{
|
||||
if (PanelLayer >= EPanelLayer.Cache)
|
||||
{
|
||||
Debug.LogError($" {name} 层级类型 选择错误 请重新选择");
|
||||
PanelLayer = EPanelLayer.Panel;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private bool ShowAutoCheckBtn()
|
||||
{
|
||||
if (!UIOperationHelper.CheckUIOperation(false)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
[GUIColor(1, 1, 0)]
|
||||
[Button("自动检查所有", 30)]
|
||||
[PropertyOrder(-100)]
|
||||
[ShowIf("ShowAutoCheckBtn")]
|
||||
private void AutoCheckBtn()
|
||||
{
|
||||
AutoCheck();
|
||||
}
|
||||
|
||||
[GUIColor(1, 1, 1)]
|
||||
[Button("重置子预制", 20)]
|
||||
[PropertyOrder(-100)]
|
||||
[ShowIf("ShowAutoCheckBtn")]
|
||||
private void RevertPrefabInstance()
|
||||
{
|
||||
UnityTipsHelper.CallBack("将会重置所有子CDE 还原到预制初始状态 \n(防止嵌套预制修改)",
|
||||
() =>
|
||||
{
|
||||
UICreateModule.RefreshChildCdeTable(this);
|
||||
foreach (var cdeTable in AllChildCdeTable)
|
||||
{
|
||||
try
|
||||
{
|
||||
PrefabUtility.RevertPrefabInstance(cdeTable.gameObject, InteractionMode.AutomatedAction);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"这个CDETable 不是预制体 请检查 {cdeTable.name}\n{e.Message}", cdeTable.gameObject);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[GUIColor(0, 1, 1)]
|
||||
[Button("保存选中", 50)]
|
||||
[PropertyOrder(-100)]
|
||||
[HideIf("ShowCreateBtn")]
|
||||
private void SaveSelectSelf()
|
||||
{
|
||||
var stage = PrefabStageUtility.GetPrefabStage(gameObject);
|
||||
|
||||
if (stage == null)
|
||||
{
|
||||
Debug.LogError($"未知错误 没有找到预制 {gameObject.name}");
|
||||
return;
|
||||
}
|
||||
|
||||
var methodInfo = stage.GetType().GetMethod("Save", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
|
||||
if (methodInfo != null)
|
||||
{
|
||||
bool result = (bool)methodInfo.Invoke(stage, null);
|
||||
if (!result)
|
||||
{
|
||||
Debug.LogError("自动保存失败 注意请手动保存");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Save方法不存在 自动保存失败 注意请手动保存");
|
||||
}
|
||||
|
||||
var assetObj = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(stage.assetPath);
|
||||
EditorGUIUtility.PingObject(assetObj);
|
||||
Selection.activeObject = assetObj;
|
||||
}
|
||||
|
||||
internal bool AutoCheck()
|
||||
{
|
||||
if (!UIOperationHelper.CheckUIOperation(this)) return false;
|
||||
if (!UICreateModule.InitVoName(this)) return false;
|
||||
OnValueChangedEUICodeType();
|
||||
OnValueChangedEPanelLayer();
|
||||
if (UICodeType == EUICodeType.Panel && IsSplitData)
|
||||
{
|
||||
PanelSplitData.Panel = gameObject;
|
||||
if (!PanelSplitData.AutoCheck()) return false;
|
||||
}
|
||||
|
||||
UICreateModule.RefreshChildCdeTable(this);
|
||||
ComponentTable?.AutoCheck();
|
||||
DataTable?.AutoCheck();
|
||||
EventTable?.AutoCheck();
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ShowCreateBtnByHierarchy()
|
||||
{
|
||||
if (string.IsNullOrEmpty(PkgName) || string.IsNullOrEmpty(ResName)) return false;
|
||||
if (ResName.Contains("Source")) return false;
|
||||
if (!UIOperationHelper.CheckUIOperation(this, false)) return false;
|
||||
return !PrefabUtility.IsPartOfPrefabAsset(this);
|
||||
}
|
||||
|
||||
[GUIColor(0f, 0.5f, 1f)]
|
||||
[Button("生成", 50)]
|
||||
[ShowIf("ShowCreateBtnByHierarchy")]
|
||||
internal void CreateUICodeByHierarchy()
|
||||
{
|
||||
if (!ShowCreateBtnByHierarchy()) return;
|
||||
|
||||
var prefabStage = UnityEditor.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
|
||||
if (prefabStage == null)
|
||||
{
|
||||
Debug.LogError($"当前不在预制体编辑器模式下");
|
||||
return;
|
||||
}
|
||||
|
||||
var path = prefabStage.assetPath;
|
||||
var root = prefabStage.prefabContentsRoot;
|
||||
PrefabUtility.SaveAsPrefabAsset(root, path, out var success);
|
||||
if (!success)
|
||||
{
|
||||
Debug.LogError("快捷保存失败 请检查");
|
||||
return;
|
||||
}
|
||||
|
||||
prefabStage.ClearDirtiness();
|
||||
|
||||
var cdeTable = AssetDatabase.LoadAssetAtPath<UIBindCDETable>(path);
|
||||
if (cdeTable == null) return;
|
||||
cdeTable.CreateUICode();
|
||||
|
||||
AssetDatabase.OpenAsset(cdeTable);
|
||||
}
|
||||
|
||||
private bool ShowCreateBtn()
|
||||
{
|
||||
if (IsSplitData) return false;
|
||||
if (!UIOperationHelper.CheckUIOperationAll(this, false)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
[GUIColor(0.7f, 0.4f, 0.8f)]
|
||||
[Button("生成", 50)]
|
||||
[ShowIf("ShowCreateBtn")]
|
||||
internal void CreateUICode()
|
||||
{
|
||||
if (!UIOperationHelper.CheckUIOperation(this)) return;
|
||||
|
||||
CreateUICode(true, true);
|
||||
}
|
||||
|
||||
private bool ShowPanelSourceSplit()
|
||||
{
|
||||
if (!UIOperationHelper.CheckUIOperationAll(this, false)) return false;
|
||||
return IsSplitData;
|
||||
}
|
||||
|
||||
[GUIColor(0f, 0.4f, 0.8f)]
|
||||
[Button("源数据拆分", 50)]
|
||||
[ShowIf("ShowPanelSourceSplit")]
|
||||
internal void PanelSourceSplit()
|
||||
{
|
||||
if (!UIOperationHelper.CheckUIOperation(this)) return;
|
||||
|
||||
if (IsSplitData)
|
||||
{
|
||||
if (AutoCheck())
|
||||
{
|
||||
UIPanelSourceSplit.Do(this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UnityTipsHelper.ShowError($"{name} 当前数据不是源数据 无法进行拆分 请检查数据");
|
||||
}
|
||||
}
|
||||
|
||||
internal void CreateUICode(bool refresh, bool tips)
|
||||
{
|
||||
UICreateModule.Create(this, refresh, tips);
|
||||
}
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
ComponentTable ??= GetComponent<UIBindComponentTable>();
|
||||
DataTable ??= GetComponent<UIBindDataTable>();
|
||||
EventTable ??= GetComponent<UIBindEventTable>();
|
||||
}
|
||||
|
||||
private void AddComponentTable()
|
||||
{
|
||||
if (!UIOperationHelper.CheckUIOperation()) return;
|
||||
|
||||
ComponentTable = gameObject.GetOrAddComponent<UIBindComponentTable>();
|
||||
}
|
||||
|
||||
private void AddDataTable()
|
||||
{
|
||||
if (!UIOperationHelper.CheckUIOperation()) return;
|
||||
|
||||
DataTable = gameObject.GetOrAddComponent<UIBindDataTable>();
|
||||
}
|
||||
|
||||
private void AddEventTable()
|
||||
{
|
||||
if (!UIOperationHelper.CheckUIOperation()) return;
|
||||
|
||||
EventTable = gameObject.GetOrAddComponent<UIBindEventTable>();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIBindCDETable_Editor.cs.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIBindCDETable_Editor.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc56a5993b8c4d65aba9966b4389ecfd
|
||||
timeCreated: 1685499334
|
||||
84
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIBindCDETable_Life.cs
vendored
Normal file
84
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIBindCDETable_Life.cs
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
//生命周期
|
||||
public sealed partial class UIBindCDETable
|
||||
{
|
||||
/// <summary>
|
||||
/// 关联UIBase
|
||||
/// 由UIBase初始化后调用
|
||||
/// 目前还没用 预留这里而已 不知道以后是否会有用
|
||||
/// </summary>
|
||||
internal void BindUIBase(UIBase uiBase)
|
||||
{
|
||||
if (m_UIBase != null)
|
||||
{
|
||||
Debug.LogError($"{gameObject.name} m_UIBase 已存在 请检查为何重复调用");
|
||||
}
|
||||
|
||||
m_UIBase = uiBase;
|
||||
}
|
||||
|
||||
internal Action UIBaseOnEnable;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
try
|
||||
{
|
||||
UIBaseOnEnable?.Invoke();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal Action UIBaseStart;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
try
|
||||
{
|
||||
UIBaseStart?.Invoke();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal Action UIBaseOnDisable;
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
try
|
||||
{
|
||||
UIBaseOnDisable?.Invoke();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal Action UIBaseOnDestroy;
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
try
|
||||
{
|
||||
UIBaseOnDestroy?.Invoke();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIBindCDETable_Life.cs.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIBindCDETable_Life.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 27ce269d96c04f9180948aa332daca61
|
||||
timeCreated: 1685499423
|
||||
46
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIBindCDETable_Panel.cs
vendored
Normal file
46
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIBindCDETable_Panel.cs
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.Serialization;
|
||||
using YIUIBind;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
//Panel的分块数据
|
||||
public sealed partial class UIBindCDETable
|
||||
{
|
||||
[OdinSerialize]
|
||||
[LabelText("源数据")]
|
||||
[ReadOnly]
|
||||
#if !YIUIMACRO_BIND_RUNTIME_EDITOR
|
||||
[HideInInspector]
|
||||
#endif
|
||||
internal bool IsSplitData;
|
||||
|
||||
//源数据 拆分前的源数据
|
||||
[ShowInInspector]
|
||||
[HideLabel]
|
||||
[BoxGroup("面板拆分数据", centerLabel: true)]
|
||||
[OdinSerialize]
|
||||
#if UNITY_EDITOR
|
||||
[ShowIf("ShowPanelSplitData")]
|
||||
#endif
|
||||
internal UIPanelSplitData PanelSplitData = new UIPanelSplitData();
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private bool ShowPanelSplitData => IsSplitData && UICodeType == EUICodeType.Panel;
|
||||
|
||||
//拆分后的引用数据
|
||||
[ShowInInspector]
|
||||
[HideLabel]
|
||||
[BoxGroup("面板拆分数据", centerLabel: true)]
|
||||
[OdinSerialize]
|
||||
[HideIf("HidePanelSplitData")]
|
||||
[ReadOnly] //就是一个只读的 展示用数据 请不要使用此数据 或修改数据
|
||||
internal UIPanelSplitData PanelSplitEditorShowData;
|
||||
|
||||
private bool HidePanelSplitData => IsSplitData || UICodeType != EUICodeType.Panel;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIBindCDETable_Panel.cs.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIBindCDETable_Panel.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b2b83a76b2d47dd8f9c315b4f345ad0
|
||||
timeCreated: 1685499635
|
||||
40
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIPanelSplitData.cs
vendored
Normal file
40
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIPanelSplitData.cs
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// 面板拆分数据
|
||||
/// 主要做分块加载
|
||||
/// </summary>
|
||||
[HideReferenceObjectPicker]
|
||||
[HideLabel]
|
||||
public sealed partial class UIPanelSplitData
|
||||
{
|
||||
[HideInInspector]
|
||||
public GameObject Panel;
|
||||
|
||||
[BoxGroup("通用界面", centerLabel: true)]
|
||||
[LabelText("所有子界面父对象")]
|
||||
[ReadOnly]
|
||||
public RectTransform AllViewParent;
|
||||
|
||||
[BoxGroup("通用界面", centerLabel: true)]
|
||||
[LabelText("所有通用界面(已存在不创建的)")]
|
||||
public List<RectTransform> AllCommonView = new List<RectTransform>();
|
||||
|
||||
[BoxGroup("通用界面", centerLabel: true)]
|
||||
[LabelText("所有需要被创建的界面")]
|
||||
public List<RectTransform> AllCreateView = new List<RectTransform>();
|
||||
|
||||
[BoxGroup("弹窗界面", centerLabel: true)]
|
||||
[LabelText("所有弹出界面父级")]
|
||||
[ReadOnly]
|
||||
public RectTransform AllPopupViewParent;
|
||||
|
||||
[BoxGroup("弹窗界面", centerLabel: true)]
|
||||
[LabelText("所有弹出界面")]
|
||||
public List<RectTransform> AllPopupView = new List<RectTransform>();
|
||||
}
|
||||
}
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIPanelSplitData.cs.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIPanelSplitData.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ff53ae7ba11434bb3aee38b3010aa48
|
||||
timeCreated: 1683700753
|
||||
240
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIPanelSplitData_Editor.cs
vendored
Normal file
240
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIPanelSplitData_Editor.cs
vendored
Normal file
@@ -0,0 +1,240 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.Serialization;
|
||||
using UnityEngine;
|
||||
using YIUIBind;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
public sealed partial class UIPanelSplitData
|
||||
{
|
||||
[OdinSerialize]
|
||||
[LabelText("生成通用界面枚举")]
|
||||
[ShowIf("ShowCreatePanelViewEnum")]
|
||||
internal bool CreatePanelViewEnum = true;
|
||||
|
||||
internal bool ShowCreatePanelViewEnum()
|
||||
{
|
||||
return (AllCommonView.Count + AllCreateView.Count) >= 1;
|
||||
}
|
||||
|
||||
private bool ShowCheckBtn()
|
||||
{
|
||||
if (Panel == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Panel.name.EndsWith(UIStaticHelper.UISource))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[GUIColor(0, 1, 1)]
|
||||
[Button("检查拆分数据", 30)]
|
||||
[ShowIf("ShowCheckBtn")]
|
||||
private void AutoCheckBtn()
|
||||
{
|
||||
AutoCheck();
|
||||
}
|
||||
|
||||
internal bool AutoCheck()
|
||||
{
|
||||
if (!ResetParent()) return false;
|
||||
|
||||
if (!CheckPanelName()) return false;
|
||||
|
||||
CheckViewName(AllCommonView);
|
||||
CheckViewName(AllCreateView);
|
||||
CheckViewName(AllPopupView);
|
||||
|
||||
CheckViewParent(AllCommonView, AllViewParent);
|
||||
CheckViewParent(AllCreateView, AllViewParent);
|
||||
CheckViewParent(AllPopupView, AllPopupViewParent);
|
||||
|
||||
var hashList = new HashSet<RectTransform>();
|
||||
CheckRepetition(ref hashList, AllCommonView);
|
||||
CheckRepetition(ref hashList, AllCreateView);
|
||||
CheckRepetition(ref hashList, AllPopupView);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ResetParent()
|
||||
{
|
||||
if (Panel == null)
|
||||
{
|
||||
Debug.LogError($"没有找到 Panel");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (AllViewParent == null || AllViewParent.name != UIStaticHelper.UIAllViewParentName)
|
||||
{
|
||||
AllViewParent = Panel.transform.FindChildByName(UIStaticHelper.UIAllViewParentName)
|
||||
.GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
if (AllViewParent == null)
|
||||
{
|
||||
Debug.LogError($"没有找到 {Panel.name} {UIStaticHelper.UIAllViewParentName} 这是必须存在的组件 你可以不用 但是不能没有");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (AllPopupViewParent == null || AllPopupViewParent.name != UIStaticHelper.UIAllPopupViewParentName)
|
||||
{
|
||||
AllPopupViewParent = Panel.transform.FindChildByName(UIStaticHelper.UIAllPopupViewParentName)
|
||||
.GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
if (AllPopupViewParent == null)
|
||||
{
|
||||
Debug.LogError($"没有找到 {Panel.name} {UIStaticHelper.UIAllPopupViewParentName} 这是必须存在的组件 你可以不用 但是不能没有");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool CheckPanelName()
|
||||
{
|
||||
var qualifiedName = NameUtility.ToFirstUpper(Panel.name);
|
||||
if (Panel.name != qualifiedName)
|
||||
{
|
||||
Panel.name = qualifiedName;
|
||||
}
|
||||
|
||||
if (Panel.name == UIStaticHelper.UIYIUIPanelSourceName)
|
||||
{
|
||||
Debug.LogError($"当前是默认名称 请手动修改名称 Xxx{UIStaticHelper.UIPanelSourceName}");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Panel.name.EndsWith($"{UIStaticHelper.UIPanelSourceName}"))
|
||||
{
|
||||
Debug.LogError($"{Panel.name} 命名必须以 {UIStaticHelper.UIPanelSourceName} 结尾 请勿随意修改");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//命名检查
|
||||
private void CheckViewName(List<RectTransform> list)
|
||||
{
|
||||
for (var i = list.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var current = list[i];
|
||||
if (current == null)
|
||||
{
|
||||
list.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
var qualifiedName = NameUtility.ToFirstUpper(current.name);
|
||||
if (current.name != qualifiedName)
|
||||
{
|
||||
current.name = qualifiedName;
|
||||
}
|
||||
|
||||
if (current.name == UIStaticHelper.UIYIUIViewParentName)
|
||||
{
|
||||
Debug.LogError($"当前是默认名称 请手动修改名称 Xxx{UIStaticHelper.UIViewParentName}");
|
||||
list.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!current.name.EndsWith(UIStaticHelper.UIViewParentName))
|
||||
{
|
||||
Debug.LogError($"{current.name} 命名必须以 {UIStaticHelper.UIViewParentName} 结尾 请勿随意修改");
|
||||
list.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
var viewName = current.name.Replace(UIStaticHelper.UIParentName, "");
|
||||
var viewCde = current.GetComponentInChildren<UIBindCDETable>();
|
||||
|
||||
if (viewCde == null)
|
||||
{
|
||||
//如果这个子物体被隐藏了
|
||||
if (current.transform.childCount >= 1)
|
||||
{
|
||||
var firstChild = current.transform.GetChild(0);
|
||||
viewCde = firstChild.GetComponent<UIBindCDETable>();
|
||||
}
|
||||
}
|
||||
|
||||
if (viewCde == null)
|
||||
{
|
||||
Debug.LogError($" {current.name} 父物体下必须有View 但是未找到View 请使用 右键 YIUI/Create UIView 创建符合要求的结构");
|
||||
list.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
viewCde.gameObject.name = viewName;
|
||||
}
|
||||
}
|
||||
|
||||
//检查null / 父级
|
||||
private void CheckViewParent(List<RectTransform> list, RectTransform parent)
|
||||
{
|
||||
for (var i = list.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (list[i] == null)
|
||||
{
|
||||
list.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
var current = list[i];
|
||||
|
||||
var parentP = current.parent;
|
||||
if (parentP == null)
|
||||
{
|
||||
list.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (parentP != parent)
|
||||
{
|
||||
list.RemoveAt(i);
|
||||
|
||||
//因为只有2个父级 所以如果不是这个就会自动帮你移动到另外一个上面
|
||||
//如果多了还是不要自动了
|
||||
var currentParentName = parentP.name;
|
||||
if (currentParentName == UIStaticHelper.UIAllViewParentName)
|
||||
{
|
||||
AllCreateView.Add(current);
|
||||
}
|
||||
else if (currentParentName == UIStaticHelper.UIAllPopupViewParentName)
|
||||
{
|
||||
AllPopupView.Add(current);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//检查重复
|
||||
private void CheckRepetition(ref HashSet<RectTransform> hashList, List<RectTransform> list)
|
||||
{
|
||||
for (var i = list.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var current = list[i];
|
||||
if (hashList.Contains(current))
|
||||
{
|
||||
list.RemoveAt(i);
|
||||
Debug.LogError($"{Panel.name} / {current.name} 重复存在 已移除 请检查");
|
||||
}
|
||||
else
|
||||
{
|
||||
hashList.Add(current);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIPanelSplitData_Editor.cs.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Code/UIPanelSplitData_Editor.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 116fc62782e44221bb7644696b4e60d5
|
||||
timeCreated: 1685605176
|
||||
Reference in New Issue
Block a user