From 7ef52245acb8a9fa25b088e723f03106ab7d5faa Mon Sep 17 00:00:00 2001 From: ALEXTANG <574809918@qq.com> Date: Mon, 3 Apr 2023 18:54:48 +0800 Subject: [PATCH] UIComponent UIComponent --- Assets/Scenes/main.unity | 28 ++++ .../Editor/Inspector/UIComponentInspector.cs | 69 ++++++++++ .../Inspector/UIComponentInspector.cs.meta | 3 + Assets/TEngine/Runtime/GameFramework/UI.meta | 3 + .../GameFramework/UI/DefaultUIWindowHelper.cs | 77 +++++++++++ .../UI/DefaultUIWindowHelper.cs.meta | 3 + .../Runtime/GameFramework/UI/IUIBehaviour.cs | 13 ++ .../GameFramework/UI/IUIBehaviour.cs.meta | 3 + .../Runtime/GameFramework/UI/IUIGroup.cs | 114 ++++++++++++++++ .../Runtime/GameFramework/UI/IUIGroup.cs.meta | 3 + .../Runtime/GameFramework/UI/UIBase.cs | 7 + .../Runtime/GameFramework/UI/UIBase.cs.meta | 3 + .../Runtime/GameFramework/UI/UIComponent.cs | 124 ++++++++++++++++++ .../GameFramework/UI/UIComponent.cs.meta | 3 + .../Runtime/GameFramework/UI/UIGroup.meta | 3 + .../UI/UIGroup/DefaultUIGroupHelper.cs | 44 +++++++ .../UI/UIGroup/DefaultUIGroupHelper.cs.meta | 3 + .../UI/UIGroup/UIComponent.UIGroup.cs | 34 +++++ .../UI/UIGroup/UIComponent.UIGroup.cs.meta | 3 + .../UI/UIGroup/UIGroupHelperBase.cs | 16 +++ .../UI/UIGroup/UIGroupHelperBase.cs.meta | 3 + .../Runtime/GameFramework/UI/UIManager.cs | 7 + .../GameFramework/UI/UIManager.cs.meta | 3 + .../Runtime/GameFramework/UI/UIWindow.cs | 7 + .../Runtime/GameFramework/UI/UIWindow.cs.meta | 3 + .../GameFramework/UI/UIWindowHelperBase.cs | 33 +++++ .../UI/UIWindowHelperBase.cs.meta | 11 ++ .../GameFramework/UI/WindowAttribute.cs | 24 ++++ .../GameFramework/UI/WindowAttribute.cs.meta | 3 + 29 files changed, 650 insertions(+) create mode 100644 Assets/TEngine/Editor/Inspector/UIComponentInspector.cs create mode 100644 Assets/TEngine/Editor/Inspector/UIComponentInspector.cs.meta create mode 100644 Assets/TEngine/Runtime/GameFramework/UI.meta create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/DefaultUIWindowHelper.cs create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/DefaultUIWindowHelper.cs.meta create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/IUIBehaviour.cs create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/IUIBehaviour.cs.meta create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/IUIGroup.cs create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/IUIGroup.cs.meta create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/UIBase.cs create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/UIBase.cs.meta create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/UIComponent.cs create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/UIComponent.cs.meta create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/UIGroup.meta create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/UIGroup/DefaultUIGroupHelper.cs create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/UIGroup/DefaultUIGroupHelper.cs.meta create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/UIGroup/UIComponent.UIGroup.cs create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/UIGroup/UIComponent.UIGroup.cs.meta create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/UIGroup/UIGroupHelperBase.cs create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/UIGroup/UIGroupHelperBase.cs.meta create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/UIManager.cs create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/UIManager.cs.meta create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/UIWindow.cs create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/UIWindow.cs.meta create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/UIWindowHelperBase.cs create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/UIWindowHelperBase.cs.meta create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/WindowAttribute.cs create mode 100644 Assets/TEngine/Runtime/GameFramework/UI/WindowAttribute.cs.meta diff --git a/Assets/Scenes/main.unity b/Assets/Scenes/main.unity index 85166389..b2e15c48 100644 --- a/Assets/Scenes/main.unity +++ b/Assets/Scenes/main.unity @@ -162,6 +162,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 43232120} + - component: {fileID: 43232121} m_Layer: 0 m_Name: UI m_TagString: Untagged @@ -183,6 +184,33 @@ Transform: m_Father: {fileID: 2061060682} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &43232121 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 43232119} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9497504d71104685ad1464b42219c763, type: 3} + m_Name: + m_EditorClassIdentifier: + m_InstanceRoot: {fileID: 88107082} + m_UICamera: {fileID: 110205813} + m_UIWindowHelperTypeName: TEngine.DefaultUIWindowHelper + mCustomUIWindowHelper: {fileID: 0} + m_UIGroupHelperTypeName: TEngine.DefaultUIGroupHelper + m_CustomUIGroupHelper: {fileID: 0} + m_UIGroups: + - m_Name: Bottom + m_Depth: 0 + - m_Name: UI + m_Depth: 1 + - m_Name: Top + m_Depth: 2 + - m_Name: System + m_Depth: 3 --- !u!1 &88107081 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/TEngine/Editor/Inspector/UIComponentInspector.cs b/Assets/TEngine/Editor/Inspector/UIComponentInspector.cs new file mode 100644 index 00000000..87a20b9d --- /dev/null +++ b/Assets/TEngine/Editor/Inspector/UIComponentInspector.cs @@ -0,0 +1,69 @@ +using UnityEditor; + +namespace TEngine.Editor.Inspector +{ + [CustomEditor(typeof(UIComponent))] + internal sealed class UIComponentInspector : GameFrameworkInspector + { + private SerializedProperty m_InstanceRoot = null; + private SerializedProperty m_UICamera = null; + private SerializedProperty m_UIGroups = null; + + private HelperInfo m_UIWindowHelperInfo = new HelperInfo("UIWindow"); + private HelperInfo m_UIGroupHelperInfo = new HelperInfo("UIGroup"); + + public override void OnInspectorGUI() + { + base.OnInspectorGUI(); + + serializedObject.Update(); + + UIComponent t = (UIComponent)target; + + EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode); + { + EditorGUILayout.PropertyField(m_InstanceRoot); + EditorGUILayout.PropertyField(m_UICamera); + m_UIWindowHelperInfo.Draw(); + m_UIGroupHelperInfo.Draw(); + EditorGUILayout.PropertyField(m_UIGroups, true); + } + EditorGUI.EndDisabledGroup(); + + if (EditorApplication.isPlaying && IsPrefabInHierarchy(t.gameObject)) + { + EditorGUILayout.LabelField("UI Group Count", t.UIGroupCount.ToString()); + } + + serializedObject.ApplyModifiedProperties(); + + Repaint(); + } + + protected override void OnCompileComplete() + { + base.OnCompileComplete(); + + RefreshTypeNames(); + } + + private void OnEnable() + { + m_InstanceRoot = serializedObject.FindProperty("m_InstanceRoot"); + m_UICamera = serializedObject.FindProperty("m_UICamera"); + m_UIGroups = serializedObject.FindProperty("m_UIGroups"); + + m_UIWindowHelperInfo.Init(serializedObject); + m_UIGroupHelperInfo.Init(serializedObject); + + RefreshTypeNames(); + } + + private void RefreshTypeNames() + { + m_UIWindowHelperInfo.Refresh(); + m_UIGroupHelperInfo.Refresh(); + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/TEngine/Editor/Inspector/UIComponentInspector.cs.meta b/Assets/TEngine/Editor/Inspector/UIComponentInspector.cs.meta new file mode 100644 index 00000000..95d8f678 --- /dev/null +++ b/Assets/TEngine/Editor/Inspector/UIComponentInspector.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cfa63d9134ce4fad9ced6e59e3fb776f +timeCreated: 1680514613 \ No newline at end of file diff --git a/Assets/TEngine/Runtime/GameFramework/UI.meta b/Assets/TEngine/Runtime/GameFramework/UI.meta new file mode 100644 index 00000000..182bf4a4 --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2d40e71adcb74a3092602909942ff1d3 +timeCreated: 1680511299 \ No newline at end of file diff --git a/Assets/TEngine/Runtime/GameFramework/UI/DefaultUIWindowHelper.cs b/Assets/TEngine/Runtime/GameFramework/UI/DefaultUIWindowHelper.cs new file mode 100644 index 00000000..32550c3e --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/DefaultUIWindowHelper.cs @@ -0,0 +1,77 @@ +using UnityEngine; + +namespace TEngine +{ + /// + /// 默认界面辅助器。 + /// + public class DefaultUIWindowHelper : UIWindowHelperBase + { + private ResourceComponent m_ResourceComponent = null; + + private Vector2 m_Half = new Vector2(0.5f,0.5f); + + private int m_UILayer; + + private void Start() + { + m_UILayer = LayerMask.NameToLayer("UI"); + m_ResourceComponent = GameEntry.GetComponent(); + if (m_ResourceComponent == null) + { + Log.Fatal("Resource component is invalid."); + return; + } + } + + /// + /// 实例化界面。 + /// + /// 要实例化的界面资源。 + public override object InstantiateUIWindow(object uiWindowAsset) + { + return Instantiate((Object)uiWindowAsset); + } + + /// + /// 创建界面。 + /// + /// 界面实例。 + /// 界面所属的界面组。 + /// 用户自定义数据。 + /// 界面。 + public override UIWindow CreateUIWindow(object uiWindowInstance, IUIGroup uiGroup, object userData) + { + GameObject obj = uiWindowInstance as GameObject; + if (obj == null) + { + Log.Error("UI form instance is invalid."); + return null; + } + + Transform trans = obj.transform; + trans.SetParent(((MonoBehaviour)uiGroup.Helper).transform); + trans.localScale = Vector3.one; + trans.localPosition = Vector3.zero; + obj.layer = m_UILayer; + + RectTransform rectTransform = obj.GetComponent(); + rectTransform.anchorMin = m_Half; + rectTransform.anchorMax = m_Half; + rectTransform.anchoredPosition = Vector2.zero; + // return obj.GetOrAddComponent(); + return new UIWindow(); + } + + /// + /// 释放界面。 + /// + /// 要释放的界面资源。 + /// 要释放的界面实例。 + public override void ReleaseUIWindow(object uiWindowAsset, object uiWindowInstance) + { + // m_ResourceComponent.UnloadAsset(uiWindowAsset); + Destroy((Object)uiWindowInstance); + } + } +} diff --git a/Assets/TEngine/Runtime/GameFramework/UI/DefaultUIWindowHelper.cs.meta b/Assets/TEngine/Runtime/GameFramework/UI/DefaultUIWindowHelper.cs.meta new file mode 100644 index 00000000..73c4ddb8 --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/DefaultUIWindowHelper.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 22c9da1f4aa8420ab1210d65b8403993 +timeCreated: 1680514816 \ No newline at end of file diff --git a/Assets/TEngine/Runtime/GameFramework/UI/IUIBehaviour.cs b/Assets/TEngine/Runtime/GameFramework/UI/IUIBehaviour.cs new file mode 100644 index 00000000..b2523cb7 --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/IUIBehaviour.cs @@ -0,0 +1,13 @@ +namespace TEngine +{ + public interface IUIBehaviour + { + void ScriptGenerator(); + void RegisterEvent(); + void OnCreate(); + void OnUpdate(float elapseSeconds, float realElapseSeconds); + void OnClose(bool isShutdown, object userData); + void OnPause(); + void OnResume(); + } +} \ No newline at end of file diff --git a/Assets/TEngine/Runtime/GameFramework/UI/IUIBehaviour.cs.meta b/Assets/TEngine/Runtime/GameFramework/UI/IUIBehaviour.cs.meta new file mode 100644 index 00000000..acae9fb8 --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/IUIBehaviour.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3dacc243d8184148b8dfedbf13368024 +timeCreated: 1680514817 \ No newline at end of file diff --git a/Assets/TEngine/Runtime/GameFramework/UI/IUIGroup.cs b/Assets/TEngine/Runtime/GameFramework/UI/IUIGroup.cs new file mode 100644 index 00000000..3f036e74 --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/IUIGroup.cs @@ -0,0 +1,114 @@ +using System.Collections.Generic; + +namespace TEngine +{ + /// + /// 界面组接口。 + /// + public interface IUIGroup + { + /// + /// 获取界面组名称。 + /// + string Name + { + get; + } + + /// + /// 获取或设置界面组深度。 + /// + int Depth + { + get; + set; + } + + /// + /// 获取或设置界面组是否暂停。 + /// + bool Pause + { + get; + set; + } + + /// + /// 获取界面组中界面数量。 + /// + int UIWindowCount + { + get; + } + + /// + /// 获取当前界面。 + /// + UIWindow CurrentUIWindow + { + get; + } + + /// + /// 获取界面组辅助器。 + /// + UIGroupHelperBase Helper + { + get; + } + + /// + /// 界面组中是否存在界面。 + /// + /// 界面序列编号。 + /// 界面组中是否存在界面。 + bool HasUIWindow(int serialId); + + /// + /// 界面组中是否存在界面。 + /// + /// 界面资源名称。 + /// 界面组中是否存在界面。 + bool HasUIWindow(string uiWindowAssetName); + + /// + /// 从界面组中获取界面。 + /// + /// 界面序列编号。 + /// 要获取的界面。 + UIWindow GetUIWindow(int serialId); + + /// + /// 从界面组中获取界面。 + /// + /// 界面资源名称。 + /// 要获取的界面。 + UIWindow GetUIWindow(string uiWindowAssetName); + + /// + /// 从界面组中获取界面。 + /// + /// 界面资源名称。 + /// 要获取的界面。 + UIWindow[] GetUIWindows(string uiWindowAssetName); + + /// + /// 从界面组中获取界面。 + /// + /// 界面资源名称。 + /// 要获取的界面。 + void GetUIWindow(string uiWindowAssetName, List results); + + /// + /// 从界面组中获取所有界面。 + /// + /// 界面组中的所有界面。 + UIWindow[] GetAllUIWindows(); + + /// + /// 从界面组中获取所有界面。 + /// + /// 界面组中的所有界面。 + void GetAllUIWindows(List results); + } +} diff --git a/Assets/TEngine/Runtime/GameFramework/UI/IUIGroup.cs.meta b/Assets/TEngine/Runtime/GameFramework/UI/IUIGroup.cs.meta new file mode 100644 index 00000000..4531b26f --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/IUIGroup.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 02d65f2c8a574a5e902b76c27a59ce24 +timeCreated: 1680511360 \ No newline at end of file diff --git a/Assets/TEngine/Runtime/GameFramework/UI/UIBase.cs b/Assets/TEngine/Runtime/GameFramework/UI/UIBase.cs new file mode 100644 index 00000000..c6a297ce --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/UIBase.cs @@ -0,0 +1,7 @@ +namespace TEngine +{ + public class UIBase + { + + } +} \ No newline at end of file diff --git a/Assets/TEngine/Runtime/GameFramework/UI/UIBase.cs.meta b/Assets/TEngine/Runtime/GameFramework/UI/UIBase.cs.meta new file mode 100644 index 00000000..f9bb226a --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/UIBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 62c603695cbe4b8bb59a94d907ca7f65 +timeCreated: 1680514241 \ No newline at end of file diff --git a/Assets/TEngine/Runtime/GameFramework/UI/UIComponent.cs b/Assets/TEngine/Runtime/GameFramework/UI/UIComponent.cs new file mode 100644 index 00000000..84e8ecea --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/UIComponent.cs @@ -0,0 +1,124 @@ +using System; +using UnityEngine; +using UnityEngine.Serialization; + +namespace TEngine +{ + /// + /// UI组件。 + /// + [DisallowMultipleComponent] + public sealed partial class UIComponent : GameFrameworkComponent + { + private const int DefaultPriority = 0; + + [SerializeField] + private Transform m_InstanceRoot = null; + + [SerializeField] + private Camera m_UICamera = null; + + [SerializeField] + private string m_UIWindowHelperTypeName = "TEngine.DefaultUIWindowHelper"; + + [SerializeField] + private UIWindowHelperBase mCustomUIWindowHelper = null; + + [SerializeField] + private string m_UIGroupHelperTypeName = "TEngine.DefaultUIGroupHelper"; + + [SerializeField] + private UIGroupHelperBase m_CustomUIGroupHelper = null; + + [SerializeField] + private UIGroup[] m_UIGroups = null; + + public const int GROUP_DEEP = 10000; + public const int WINDOWS_DEEP = 100; + + /// + /// UI根节点。 + /// + public Transform UIRoot => m_InstanceRoot; + + /// + /// UI根节点。 + /// + public Camera UICamera => m_UICamera; + + /// + /// 获取界面组数量。 + /// + public int UIGroupCount => m_UIGroups?.Length ?? 0; + + protected override void Awake() + { + base.Awake(); + } + + private void Start() + { + RootComponent rootComponent = GameEntry.GetComponent(); + if (rootComponent == null) + { + Log.Fatal("Base component is invalid."); + return; + } + + UIWindowHelperBase uiWindowHelper = Helper.CreateHelper(m_UIWindowHelperTypeName, mCustomUIWindowHelper); + if (uiWindowHelper == null) + { + Log.Error("Can not create UI form helper."); + return; + } + + uiWindowHelper.name = "UI Form Helper"; + Transform transform = uiWindowHelper.transform; + transform.SetParent(this.transform); + transform.localScale = Vector3.one; + + if (m_InstanceRoot == null) + { + m_InstanceRoot = new GameObject("UI Form Instances").transform; + m_InstanceRoot.SetParent(gameObject.transform); + m_InstanceRoot.localScale = Vector3.one; + } + + m_InstanceRoot.gameObject.layer = LayerMask.NameToLayer("UI"); + + for (int i = 0; i < m_UIGroups.Length; i++) + { + if (!AddUIGroup(m_UIGroups[i].Name, m_UIGroups[i].Depth)) + { + Log.Warning("Add UI group '{0}' failure.", m_UIGroups[i].Name); + continue; + } + } + } + + /// + /// 增加界面组。 + /// + /// 界面组名称。 + /// 界面组深度。 + /// 是否增加界面组成功。 + public bool AddUIGroup(string uiGroupName, int depth) + { + UIGroupHelperBase uiGroupHelper = Helper.CreateHelper(m_UIGroupHelperTypeName, m_CustomUIGroupHelper, m_UIGroups.Length); + if (uiGroupHelper == null) + { + Log.Error("Can not create UI group helper."); + return false; + } + + uiGroupHelper.name = Utility.Text.Format("UI Group - {0}", uiGroupName); + uiGroupHelper.gameObject.layer = LayerMask.NameToLayer("UI"); + Transform transform = uiGroupHelper.transform; + transform.SetParent(m_InstanceRoot); + transform.localScale = Vector3.one; + transform.localPosition = Vector3.zero; + + return true; + } + } +} \ No newline at end of file diff --git a/Assets/TEngine/Runtime/GameFramework/UI/UIComponent.cs.meta b/Assets/TEngine/Runtime/GameFramework/UI/UIComponent.cs.meta new file mode 100644 index 00000000..4e380382 --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/UIComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9497504d71104685ad1464b42219c763 +timeCreated: 1680511581 \ No newline at end of file diff --git a/Assets/TEngine/Runtime/GameFramework/UI/UIGroup.meta b/Assets/TEngine/Runtime/GameFramework/UI/UIGroup.meta new file mode 100644 index 00000000..8a1fefd1 --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/UIGroup.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b10f86b28ebd47b0b9dad8bbbfa0df06 +timeCreated: 1680515210 \ No newline at end of file diff --git a/Assets/TEngine/Runtime/GameFramework/UI/UIGroup/DefaultUIGroupHelper.cs b/Assets/TEngine/Runtime/GameFramework/UI/UIGroup/DefaultUIGroupHelper.cs new file mode 100644 index 00000000..5f0c0f7f --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/UIGroup/DefaultUIGroupHelper.cs @@ -0,0 +1,44 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace TEngine +{ + /// + /// 默认界面组辅助器。 + /// + public class DefaultUIGroupHelper : UIGroupHelperBase + { + public const int DepthFactor = 10000; + private int m_Depth = 0; + private Canvas m_CachedCanvas = null; + + /// + /// 设置界面组深度。 + /// + /// 界面组深度。 + public override void SetDepth(int depth) + { + m_Depth = depth; + m_CachedCanvas.overrideSorting = true; + m_CachedCanvas.sortingOrder = DepthFactor * depth; + } + + private void Awake() + { + m_CachedCanvas = gameObject.GetOrAddComponent(); + gameObject.GetOrAddComponent(); + } + + private void Start() + { + m_CachedCanvas.overrideSorting = true; + m_CachedCanvas.sortingOrder = DepthFactor * m_Depth; + + RectTransform rectTransform = GetComponent(); + rectTransform.anchorMin = Vector2.zero; + rectTransform.anchorMax = Vector2.one; + rectTransform.anchoredPosition = Vector2.zero; + rectTransform.sizeDelta = Vector2.zero; + } + } +} diff --git a/Assets/TEngine/Runtime/GameFramework/UI/UIGroup/DefaultUIGroupHelper.cs.meta b/Assets/TEngine/Runtime/GameFramework/UI/UIGroup/DefaultUIGroupHelper.cs.meta new file mode 100644 index 00000000..03eaa464 --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/UIGroup/DefaultUIGroupHelper.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1686306ee1ba46b59e0405d121ad7cfe +timeCreated: 1680514816 \ No newline at end of file diff --git a/Assets/TEngine/Runtime/GameFramework/UI/UIGroup/UIComponent.UIGroup.cs b/Assets/TEngine/Runtime/GameFramework/UI/UIGroup/UIComponent.UIGroup.cs new file mode 100644 index 00000000..960877a9 --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/UIGroup/UIComponent.UIGroup.cs @@ -0,0 +1,34 @@ +using System; +using UnityEngine; + +namespace TEngine +{ + public sealed partial class UIComponent : GameFrameworkComponent + { + [Serializable] + private sealed class UIGroup + { + [SerializeField] + private string m_Name = null; + + [SerializeField] + private int m_Depth = 0; + + public string Name + { + get + { + return m_Name; + } + } + + public int Depth + { + get + { + return m_Depth; + } + } + } + } +} diff --git a/Assets/TEngine/Runtime/GameFramework/UI/UIGroup/UIComponent.UIGroup.cs.meta b/Assets/TEngine/Runtime/GameFramework/UI/UIGroup/UIComponent.UIGroup.cs.meta new file mode 100644 index 00000000..3ab4b636 --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/UIGroup/UIComponent.UIGroup.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e810c424ef3e4d4d819a04049d8c0cc9 +timeCreated: 1680511981 \ No newline at end of file diff --git a/Assets/TEngine/Runtime/GameFramework/UI/UIGroup/UIGroupHelperBase.cs b/Assets/TEngine/Runtime/GameFramework/UI/UIGroup/UIGroupHelperBase.cs new file mode 100644 index 00000000..59c124bf --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/UIGroup/UIGroupHelperBase.cs @@ -0,0 +1,16 @@ +using UnityEngine; + +namespace TEngine +{ + /// + /// 界面组辅助器基类。 + /// + public abstract class UIGroupHelperBase : MonoBehaviour + { + /// + /// 设置界面组深度。 + /// + /// 界面组深度。 + public abstract void SetDepth(int depth); + } +} \ No newline at end of file diff --git a/Assets/TEngine/Runtime/GameFramework/UI/UIGroup/UIGroupHelperBase.cs.meta b/Assets/TEngine/Runtime/GameFramework/UI/UIGroup/UIGroupHelperBase.cs.meta new file mode 100644 index 00000000..8fafc319 --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/UIGroup/UIGroupHelperBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 448c98ed06ca49c1bf41283abf384005 +timeCreated: 1680516245 \ No newline at end of file diff --git a/Assets/TEngine/Runtime/GameFramework/UI/UIManager.cs b/Assets/TEngine/Runtime/GameFramework/UI/UIManager.cs new file mode 100644 index 00000000..87b5f8a6 --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/UIManager.cs @@ -0,0 +1,7 @@ +namespace TEngine +{ + public class UIManager + { + + } +} \ No newline at end of file diff --git a/Assets/TEngine/Runtime/GameFramework/UI/UIManager.cs.meta b/Assets/TEngine/Runtime/GameFramework/UI/UIManager.cs.meta new file mode 100644 index 00000000..78bd6faa --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/UIManager.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5bd4d4995a5241e3b2df04687b757f47 +timeCreated: 1680511416 \ No newline at end of file diff --git a/Assets/TEngine/Runtime/GameFramework/UI/UIWindow.cs b/Assets/TEngine/Runtime/GameFramework/UI/UIWindow.cs new file mode 100644 index 00000000..02b9a877 --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/UIWindow.cs @@ -0,0 +1,7 @@ +namespace TEngine +{ + public class UIWindow + { + + } +} \ No newline at end of file diff --git a/Assets/TEngine/Runtime/GameFramework/UI/UIWindow.cs.meta b/Assets/TEngine/Runtime/GameFramework/UI/UIWindow.cs.meta new file mode 100644 index 00000000..ea55e2da --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/UIWindow.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3f7074455af14e94807e155b7cf32dd3 +timeCreated: 1680514258 \ No newline at end of file diff --git a/Assets/TEngine/Runtime/GameFramework/UI/UIWindowHelperBase.cs b/Assets/TEngine/Runtime/GameFramework/UI/UIWindowHelperBase.cs new file mode 100644 index 00000000..08299f3a --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/UIWindowHelperBase.cs @@ -0,0 +1,33 @@ +using UnityEngine; + +namespace TEngine +{ + /// + /// 界面辅助器基类。 + /// + public abstract class UIWindowHelperBase : MonoBehaviour + { + /// + /// 实例化界面。 + /// + /// 要实例化的界面资源。 + /// 实例化后的界面。 + public abstract object InstantiateUIWindow(object uiWindowAsset); + + /// + /// 创建界面。 + /// + /// 界面实例。 + /// 界面所属的界面组。 + /// 用户自定义数据。 + /// 界面。 + public abstract UIWindow CreateUIWindow(object uiWindowInstance, IUIGroup uiGroup, object userData); + + /// + /// 释放界面。 + /// + /// 要释放的界面资源。 + /// 要释放的界面实例。 + public abstract void ReleaseUIWindow(object uiWindowAsset, object uiWindowInstance); + } +} diff --git a/Assets/TEngine/Runtime/GameFramework/UI/UIWindowHelperBase.cs.meta b/Assets/TEngine/Runtime/GameFramework/UI/UIWindowHelperBase.cs.meta new file mode 100644 index 00000000..34eb860f --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/UIWindowHelperBase.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3f4ee8db1fd94cfdb66dc1062084ad30 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TEngine/Runtime/GameFramework/UI/WindowAttribute.cs b/Assets/TEngine/Runtime/GameFramework/UI/WindowAttribute.cs new file mode 100644 index 00000000..e89496f6 --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/WindowAttribute.cs @@ -0,0 +1,24 @@ +using System; + +namespace TEngine +{ + [AttributeUsage(AttributeTargets.Class)] + public class WindowAttribute : Attribute + { + /// + /// 资源实体可寻址路径/路径。 + /// + public string AssetName; + + /// + /// 全屏窗口标记。 + /// + public bool FullScreen; + + public WindowAttribute(string assetName, bool fullScreen = false) + { + AssetName = assetName; + FullScreen = fullScreen; + } + } +} \ No newline at end of file diff --git a/Assets/TEngine/Runtime/GameFramework/UI/WindowAttribute.cs.meta b/Assets/TEngine/Runtime/GameFramework/UI/WindowAttribute.cs.meta new file mode 100644 index 00000000..2342c29d --- /dev/null +++ b/Assets/TEngine/Runtime/GameFramework/UI/WindowAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0e40418539074f688c82a8ab107e968e +timeCreated: 1680511434 \ No newline at end of file