From d0e5420f955b7425d73a2782b261163c4da7c91b Mon Sep 17 00:00:00 2001 From: ninemine <1371605831@qq.com> Date: Mon, 21 Jul 2025 15:58:52 +0800 Subject: [PATCH] BS 0.2.0 Visual --- .../Resources/ES3/ES3Defaults.asset | 11 - Convention/[Runtime]/Config.cs | 958 +++++++++++++++ Convention/[Visual].meta | 8 + Convention/[Visual]/Operater.meta | 8 + .../Operater/BaseBeginDragBehaviour.cs | 16 + .../Operater/BaseBeginDragBehaviour.cs.meta | 11 + .../[Visual]/Operater/BaseCancelBehaviour.cs | 16 + .../Operater/BaseCancelBehaviour.cs.meta | 11 + .../Operater/BaseDeselectBehaviour.cs | 16 + .../Operater/BaseDeselectBehaviour.cs.meta | 11 + .../[Visual]/Operater/BaseDragBehaviour.cs | 16 + .../Operater/BaseDragBehaviour.cs.meta | 11 + .../[Visual]/Operater/BaseDropBehaviour.cs | 16 + .../Operater/BaseDropBehaviour.cs.meta | 11 + .../[Visual]/Operater/BaseEndDragBehaviour.cs | 16 + .../Operater/BaseEndDragBehaviour.cs.meta | 11 + .../BaseInitializePotentialDragBehaviour.cs | 16 + ...seInitializePotentialDragBehaviour.cs.meta | 11 + .../[Visual]/Operater/BaseMoveBehaviour.cs | 16 + .../Operater/BaseMoveBehaviour.cs.meta | 11 + .../Operater/BasePointerClickBehaviour.cs | 16 + .../BasePointerClickBehaviour.cs.meta | 11 + .../Operater/BasePointerDownBehaviour.cs | 16 + .../Operater/BasePointerDownBehaviour.cs.meta | 11 + .../Operater/BasePointerEnterBehaviour.cs | 16 + .../BasePointerEnterBehaviour.cs.meta | 11 + .../Operater/BasePointerExitBehaviour.cs | 16 + .../Operater/BasePointerExitBehaviour.cs.meta | 11 + .../Operater/BasePointerUpBehaviour.cs | 16 + .../Operater/BasePointerUpBehaviour.cs.meta | 11 + .../[Visual]/Operater/BaseScrollBehaviour.cs | 16 + .../Operater/BaseScrollBehaviour.cs.meta | 11 + .../[Visual]/Operater/BaseSelectBehaviour.cs | 16 + .../Operater/BaseSelectBehaviour.cs.meta | 11 + .../[Visual]/Operater/BaseSubmitBehaviour.cs | 16 + .../Operater/BaseSubmitBehaviour.cs.meta | 11 + .../Operater/BaseUpdateSelectedBehaviour.cs | 16 + .../BaseUpdateSelectedBehaviour.cs.meta | 11 + Convention/[Visual]/Operater/DragBehaviour.cs | 117 ++ .../[Visual]/Operater/DragBehaviour.cs.meta | 11 + Convention/[Visual]/UIComponent.meta | 8 + .../[Visual]/UIComponent/BaseWindowBar.cs | 276 +++++ .../UIComponent/BaseWindowBar.cs.meta | 11 + .../[Visual]/UIComponent/BaseWindowPlane.cs | 124 ++ .../UIComponent/BaseWindowPlane.cs.meta | 11 + .../[Visual]/UIComponent/Canvas.controller | 252 ++++ .../UIComponent/Canvas.controller.meta | 8 + Convention/[Visual]/UIComponent/ClickBoard.cs | 36 + .../[Visual]/UIComponent/ClickBoard.cs.meta | 11 + Convention/[Visual]/UIComponent/CustomMenu.cs | 49 + .../[Visual]/UIComponent/CustomMenu.cs.meta | 11 + .../[Visual]/UIComponent/FocusInspector.anim | 746 +++++++++++ .../UIComponent/FocusInspector.anim.meta | 8 + .../[Visual]/UIComponent/FocusMainWindow.anim | 1088 +++++++++++++++++ .../UIComponent/FocusMainWindow.anim.meta | 8 + .../[Visual]/UIComponent/FullMainWindow.anim | 1088 +++++++++++++++++ .../UIComponent/FullMainWindow.anim.meta | 8 + .../[Visual]/UIComponent/GradientEffect.cs | 490 ++++++++ .../UIComponent/GradientEffect.cs.meta | 11 + Convention/[Visual]/UIComponent/InputField.cs | 67 + .../[Visual]/UIComponent/InputField.cs.meta | 11 + .../[Visual]/UIComponent/KeyboardStatsBar.cs | 29 + .../UIComponent/KeyboardStatsBar.cs.meta | 11 + .../[Visual]/UIComponent/ModernUIButton.cs | 366 ++++++ .../UIComponent/ModernUIButton.cs.meta | 11 + .../[Visual]/UIComponent/ModernUIDropdown.cs | 412 +++++++ .../UIComponent/ModernUIDropdown.cs.meta | 11 + .../[Visual]/UIComponent/ModernUIFillBar.cs | 150 +++ .../UIComponent/ModernUIFillBar.cs.meta | 11 + .../[Visual]/UIComponent/ModernUIImage.cs | 22 + .../UIComponent/ModernUIImage.cs.meta | 11 + .../UIComponent/ModernUIInputField.cs | 37 + .../UIComponent/ModernUIInputField.cs.meta | 11 + .../[Visual]/UIComponent/ModernUIToggle.cs | 126 ++ .../UIComponent/ModernUIToggle.cs.meta | 11 + .../[Visual]/UIComponent/ModuleInterfaces.cs | 95 ++ .../UIComponent/ModuleInterfaces.cs.meta | 11 + Convention/[Visual]/UIComponent/ScrollView.cs | 13 + .../[Visual]/UIComponent/ScrollView.cs.meta | 11 + Convention/[Visual]/UIComponent/Text.cs | 32 + Convention/[Visual]/UIComponent/Text.cs.meta | 11 + Convention/[Visual]/UIComponent/Variant.meta | 8 + .../UIComponent/Variant/AssetsWindow.meta | 8 + .../Variant/AssetsWindow/AssetsItem.cs | 132 ++ .../Variant/AssetsWindow/AssetsItem.cs.meta | 11 + .../Variant/AssetsWindow/AssetsWindow.cs | 95 ++ .../Variant/AssetsWindow/AssetsWindow.cs.meta | 11 + .../Variant/AssetsWindow/FileSystemAssets.cs | 75 ++ .../AssetsWindow/FileSystemAssets.cs.meta | 11 + .../AssetsWindow/FileSystemAssetsItem.cs | 383 ++++++ .../AssetsWindow/FileSystemAssetsItem.cs.meta | 11 + .../UIComponent/Variant/ConsoleWindow.meta | 8 + .../Variant/ConsoleWindow/ConsoleListItem.cs | 42 + .../ConsoleWindow/ConsoleListItem.cs.meta | 11 + .../Variant/ConsoleWindow/ConsoleWindow.cs | 153 +++ .../ConsoleWindow/ConsoleWindow.cs.meta | 11 + .../Variant/ConversationWindow.meta | 8 + .../ConversationWindow/ConversationItem.cs | 26 + .../ConversationItem.cs.meta | 11 + .../ConversationWindow/ConversationWindow.cs | 76 ++ .../ConversationWindow.cs.meta | 11 + .../Variant/FocusWindowIndictaor.cs | 34 + .../Variant/FocusWindowIndictaor.cs.meta | 11 + .../UIComponent/Variant/HierarchyWindow.meta | 8 + .../Variant/HierarchyWindow/HierarchyItem.cs | 78 ++ .../HierarchyWindow/HierarchyItem.cs.meta | 11 + .../HierarchyWindow/HierarchyLoadedIn.cs | 69 ++ .../HierarchyWindow/HierarchyLoadedIn.cs.meta | 11 + .../HierarchyWindow/HierarchyWindow.cs | 135 ++ .../HierarchyWindow/HierarchyWindow.cs.meta | 11 + .../UIComponent/Variant/InspectorWindow.meta | 8 + .../InspectorWindow/InspectorButton.cs | 50 + .../InspectorWindow/InspectorButton.cs.meta | 11 + .../InspectorWindow/InspectorDictionary.cs | 10 + .../InspectorDictionary.cs.meta | 11 + .../Variant/InspectorWindow/InspectorEnum.cs | 118 ++ .../InspectorWindow/InspectorEnum.cs.meta | 11 + .../Variant/InspectorWindow/InspectorImage.cs | 78 ++ .../InspectorWindow/InspectorImage.cs.meta | 11 + .../Variant/InspectorWindow/InspectorItem.cs | 408 +++++++ .../InspectorWindow/InspectorItem.cs.meta | 11 + .../InspectorWindow/InspectorReference.cs | 70 ++ .../InspectorReference.cs.meta | 11 + .../InspectorWindow/InspectorStructure.cs | 52 + .../InspectorStructure.cs.meta | 11 + .../Variant/InspectorWindow/InspectorText.cs | 68 ++ .../InspectorWindow/InspectorText.cs.meta | 11 + .../InspectorWindow/InspectorToggle.cs | 44 + .../InspectorWindow/InspectorToggle.cs.meta | 11 + .../InspectorWindow/InspectorTransform.cs | 184 +++ .../InspectorTransform.cs.meta | 11 + .../InspectorWindow/InspectorWindow.cs | 354 ++++++ .../InspectorWindow/InspectorWindow.cs.meta | 11 + .../UIComponent/Variant/MainWindow.meta | 8 + .../Variant/MainWindow/SceneGameWindow.cs | 77 ++ .../MainWindow/SceneGameWindow.cs.meta | 11 + .../UIComponent/Variant/PropertiesWindow.cs | 484 ++++++++ .../Variant/PropertiesWindow.cs.meta | 11 + .../UIComponent/Variant/PropertyListItem.cs | 158 +++ .../Variant/PropertyListItem.cs.meta | 11 + .../UIComponent/Variant/SharedModule.cs | 95 ++ .../UIComponent/Variant/SharedModule.cs.meta | 11 + 142 files changed, 11176 insertions(+), 11 deletions(-) create mode 100644 Convention/[Visual].meta create mode 100644 Convention/[Visual]/Operater.meta create mode 100644 Convention/[Visual]/Operater/BaseBeginDragBehaviour.cs create mode 100644 Convention/[Visual]/Operater/BaseBeginDragBehaviour.cs.meta create mode 100644 Convention/[Visual]/Operater/BaseCancelBehaviour.cs create mode 100644 Convention/[Visual]/Operater/BaseCancelBehaviour.cs.meta create mode 100644 Convention/[Visual]/Operater/BaseDeselectBehaviour.cs create mode 100644 Convention/[Visual]/Operater/BaseDeselectBehaviour.cs.meta create mode 100644 Convention/[Visual]/Operater/BaseDragBehaviour.cs create mode 100644 Convention/[Visual]/Operater/BaseDragBehaviour.cs.meta create mode 100644 Convention/[Visual]/Operater/BaseDropBehaviour.cs create mode 100644 Convention/[Visual]/Operater/BaseDropBehaviour.cs.meta create mode 100644 Convention/[Visual]/Operater/BaseEndDragBehaviour.cs create mode 100644 Convention/[Visual]/Operater/BaseEndDragBehaviour.cs.meta create mode 100644 Convention/[Visual]/Operater/BaseInitializePotentialDragBehaviour.cs create mode 100644 Convention/[Visual]/Operater/BaseInitializePotentialDragBehaviour.cs.meta create mode 100644 Convention/[Visual]/Operater/BaseMoveBehaviour.cs create mode 100644 Convention/[Visual]/Operater/BaseMoveBehaviour.cs.meta create mode 100644 Convention/[Visual]/Operater/BasePointerClickBehaviour.cs create mode 100644 Convention/[Visual]/Operater/BasePointerClickBehaviour.cs.meta create mode 100644 Convention/[Visual]/Operater/BasePointerDownBehaviour.cs create mode 100644 Convention/[Visual]/Operater/BasePointerDownBehaviour.cs.meta create mode 100644 Convention/[Visual]/Operater/BasePointerEnterBehaviour.cs create mode 100644 Convention/[Visual]/Operater/BasePointerEnterBehaviour.cs.meta create mode 100644 Convention/[Visual]/Operater/BasePointerExitBehaviour.cs create mode 100644 Convention/[Visual]/Operater/BasePointerExitBehaviour.cs.meta create mode 100644 Convention/[Visual]/Operater/BasePointerUpBehaviour.cs create mode 100644 Convention/[Visual]/Operater/BasePointerUpBehaviour.cs.meta create mode 100644 Convention/[Visual]/Operater/BaseScrollBehaviour.cs create mode 100644 Convention/[Visual]/Operater/BaseScrollBehaviour.cs.meta create mode 100644 Convention/[Visual]/Operater/BaseSelectBehaviour.cs create mode 100644 Convention/[Visual]/Operater/BaseSelectBehaviour.cs.meta create mode 100644 Convention/[Visual]/Operater/BaseSubmitBehaviour.cs create mode 100644 Convention/[Visual]/Operater/BaseSubmitBehaviour.cs.meta create mode 100644 Convention/[Visual]/Operater/BaseUpdateSelectedBehaviour.cs create mode 100644 Convention/[Visual]/Operater/BaseUpdateSelectedBehaviour.cs.meta create mode 100644 Convention/[Visual]/Operater/DragBehaviour.cs create mode 100644 Convention/[Visual]/Operater/DragBehaviour.cs.meta create mode 100644 Convention/[Visual]/UIComponent.meta create mode 100644 Convention/[Visual]/UIComponent/BaseWindowBar.cs create mode 100644 Convention/[Visual]/UIComponent/BaseWindowBar.cs.meta create mode 100644 Convention/[Visual]/UIComponent/BaseWindowPlane.cs create mode 100644 Convention/[Visual]/UIComponent/BaseWindowPlane.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Canvas.controller create mode 100644 Convention/[Visual]/UIComponent/Canvas.controller.meta create mode 100644 Convention/[Visual]/UIComponent/ClickBoard.cs create mode 100644 Convention/[Visual]/UIComponent/ClickBoard.cs.meta create mode 100644 Convention/[Visual]/UIComponent/CustomMenu.cs create mode 100644 Convention/[Visual]/UIComponent/CustomMenu.cs.meta create mode 100644 Convention/[Visual]/UIComponent/FocusInspector.anim create mode 100644 Convention/[Visual]/UIComponent/FocusInspector.anim.meta create mode 100644 Convention/[Visual]/UIComponent/FocusMainWindow.anim create mode 100644 Convention/[Visual]/UIComponent/FocusMainWindow.anim.meta create mode 100644 Convention/[Visual]/UIComponent/FullMainWindow.anim create mode 100644 Convention/[Visual]/UIComponent/FullMainWindow.anim.meta create mode 100644 Convention/[Visual]/UIComponent/GradientEffect.cs create mode 100644 Convention/[Visual]/UIComponent/GradientEffect.cs.meta create mode 100644 Convention/[Visual]/UIComponent/InputField.cs create mode 100644 Convention/[Visual]/UIComponent/InputField.cs.meta create mode 100644 Convention/[Visual]/UIComponent/KeyboardStatsBar.cs create mode 100644 Convention/[Visual]/UIComponent/KeyboardStatsBar.cs.meta create mode 100644 Convention/[Visual]/UIComponent/ModernUIButton.cs create mode 100644 Convention/[Visual]/UIComponent/ModernUIButton.cs.meta create mode 100644 Convention/[Visual]/UIComponent/ModernUIDropdown.cs create mode 100644 Convention/[Visual]/UIComponent/ModernUIDropdown.cs.meta create mode 100644 Convention/[Visual]/UIComponent/ModernUIFillBar.cs create mode 100644 Convention/[Visual]/UIComponent/ModernUIFillBar.cs.meta create mode 100644 Convention/[Visual]/UIComponent/ModernUIImage.cs create mode 100644 Convention/[Visual]/UIComponent/ModernUIImage.cs.meta create mode 100644 Convention/[Visual]/UIComponent/ModernUIInputField.cs create mode 100644 Convention/[Visual]/UIComponent/ModernUIInputField.cs.meta create mode 100644 Convention/[Visual]/UIComponent/ModernUIToggle.cs create mode 100644 Convention/[Visual]/UIComponent/ModernUIToggle.cs.meta create mode 100644 Convention/[Visual]/UIComponent/ModuleInterfaces.cs create mode 100644 Convention/[Visual]/UIComponent/ModuleInterfaces.cs.meta create mode 100644 Convention/[Visual]/UIComponent/ScrollView.cs create mode 100644 Convention/[Visual]/UIComponent/ScrollView.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Text.cs create mode 100644 Convention/[Visual]/UIComponent/Text.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/AssetsWindow.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/AssetsWindow/AssetsItem.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/AssetsWindow/AssetsItem.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/AssetsWindow/AssetsWindow.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/AssetsWindow/AssetsWindow.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/AssetsWindow/FileSystemAssets.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/AssetsWindow/FileSystemAssets.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/AssetsWindow/FileSystemAssetsItem.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/AssetsWindow/FileSystemAssetsItem.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/ConsoleWindow.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/ConsoleWindow/ConsoleListItem.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/ConsoleWindow/ConsoleListItem.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/ConsoleWindow/ConsoleWindow.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/ConsoleWindow/ConsoleWindow.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/ConversationWindow.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/ConversationWindow/ConversationItem.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/ConversationWindow/ConversationItem.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/ConversationWindow/ConversationWindow.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/ConversationWindow/ConversationWindow.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/FocusWindowIndictaor.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/FocusWindowIndictaor.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/HierarchyWindow.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/HierarchyWindow/HierarchyItem.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/HierarchyWindow/HierarchyItem.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/HierarchyWindow/HierarchyLoadedIn.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/HierarchyWindow/HierarchyLoadedIn.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/HierarchyWindow/HierarchyWindow.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/HierarchyWindow/HierarchyWindow.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/InspectorWindow.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/InspectorWindow/InspectorButton.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/InspectorWindow/InspectorButton.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/InspectorWindow/InspectorDictionary.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/InspectorWindow/InspectorDictionary.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/InspectorWindow/InspectorEnum.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/InspectorWindow/InspectorEnum.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/InspectorWindow/InspectorImage.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/InspectorWindow/InspectorImage.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/InspectorWindow/InspectorItem.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/InspectorWindow/InspectorItem.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/InspectorWindow/InspectorReference.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/InspectorWindow/InspectorReference.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/InspectorWindow/InspectorStructure.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/InspectorWindow/InspectorStructure.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/InspectorWindow/InspectorText.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/InspectorWindow/InspectorText.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/InspectorWindow/InspectorToggle.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/InspectorWindow/InspectorToggle.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/InspectorWindow/InspectorTransform.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/InspectorWindow/InspectorTransform.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/InspectorWindow/InspectorWindow.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/InspectorWindow/InspectorWindow.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/MainWindow.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/MainWindow/SceneGameWindow.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/MainWindow/SceneGameWindow.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/PropertiesWindow.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/PropertiesWindow.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/PropertyListItem.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/PropertyListItem.cs.meta create mode 100644 Convention/[Visual]/UIComponent/Variant/SharedModule.cs create mode 100644 Convention/[Visual]/UIComponent/Variant/SharedModule.cs.meta diff --git a/Convention/[ES3]/Easy Save 3/Resources/ES3/ES3Defaults.asset b/Convention/[ES3]/Easy Save 3/Resources/ES3/ES3Defaults.asset index 73cf3c7..c2ecb5c 100644 --- a/Convention/[ES3]/Easy Save 3/Resources/ES3/ES3Defaults.asset +++ b/Convention/[ES3]/Easy Save 3/Resources/ES3/ES3Defaults.asset @@ -30,21 +30,10 @@ MonoBehaviour: referenceMode: 2 serializationDepthLimit: 64 assemblyNames: - - AimingRig - Assembly-CSharp - Assembly-CSharp-firstpass - Cinemachine - - Convention.Plugin - - Convention.Runtime - - Convention.Windows - - CW.Common - - Dreamteck.Splines - - Dreamteck.Utilities - EasySave3 - - IngameDebugConsole.Runtime - - LeanCommon - - LeanPool - - WorkflowAgent showAdvancedSettings: 0 addMgrToSceneAutomatically: 0 autoUpdateReferences: 1 diff --git a/Convention/[Runtime]/Config.cs b/Convention/[Runtime]/Config.cs index d977b78..27f84ea 100644 --- a/Convention/[Runtime]/Config.cs +++ b/Convention/[Runtime]/Config.cs @@ -1,10 +1,19 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Runtime.InteropServices; using System.Threading; +using Sirenix.Utilities; +using UnityEditor; using UnityEngine; +using UnityEngine.Events; + +namespace UnityEditor +{ + +} namespace Convention { @@ -398,3 +407,952 @@ namespace Convention } } } + +namespace Convention +{ + public static partial class ConventionUtility + { + //[MethodImpl(MethodImplOptions.AggressiveInlining)] + public static string convert_xstring([In] object obj) + { + return Convert.ToString(obj); + } + public static _T convert_xvalue<_T>([In] string str) + { + Type type = typeof(_T); + var parse_method = type.GetMethod("Parse"); + if (parse_method != null && + (parse_method.ReturnType.IsSubclassOf(type) || parse_method.ReturnType == type) && + parse_method.GetParameters().Length == 1 && + parse_method.GetParameters()[0].ParameterType == typeof(string)) + { + return (_T)parse_method.Invoke(null, new object[] { str }); + } + + throw new InvalidCastException($"\"{str}\" is cannt convert to type<{type}>"); + } + public static string Combine([In] params object[] args) + { + if (args.Length == 0) + return ""; + if (args.Length == 1) + return args[0].ToString(); + return Combine(args[0]) + Combine(args[1..]); + } + public static string Trim([In] string str, int left_right_flag = 3) + { + string result = new string(str); + if ((left_right_flag & (1 << 0)) == 1) + result = result.TrimStart(); + if ((left_right_flag & (1 << 1)) == 1) + result = result.TrimEnd(); + return result; + } + + public static object SeekValue([In] object obj, [In] string name, BindingFlags flags, [Out][Opt] out bool isSucceed) + { + Type type = obj.GetType(); + var field = type.GetField(name, flags); + isSucceed = true; + if (field != null) + { + return field.GetValue(obj); + } + var property = type.GetProperty(name, flags); + if (property != null) + { + return property.GetValue(obj); + } + isSucceed = false; + return null; + } + public static object SeekValue([In] object obj, [In] string name, BindingFlags flags) + { + Type type = obj.GetType(); + var field = type.GetField(name, flags); + if (field != null) + { + return field.GetValue(obj); + } + var property = type.GetProperty(name, flags); + if (property != null) + { + return property.GetValue(obj); + } + return null; + } + public static object SeekValue([In] object obj, [In] string name, [In] Type valueType, BindingFlags flags, [Out][Opt] out bool isSucceed) + { + Type type = obj.GetType(); + var field = type.GetField(name, flags); + isSucceed = true; + if (field != null && field.FieldType == valueType) + { + return field.GetValue(obj); + } + var property = type.GetProperty(name, flags); + if (property != null && property.PropertyType == valueType) + { + return property.GetValue(obj); + } + isSucceed = false; + return null; + } + public static object SeekValue([In] object obj, [In] string name, [In] Type valueType, BindingFlags flags) + { + Type type = obj.GetType(); + var field = type.GetField(name, flags); + if (field != null && field.FieldType == valueType) + { + return field.GetValue(obj); + } + var property = type.GetProperty(name, flags); + if (property != null && property.PropertyType == valueType) + { + return property.GetValue(obj); + } + return null; + } + public static bool PushValue([In] object obj, [In] object value, [In] string name, BindingFlags flags) + { + Type type = obj.GetType(); + var field = type.GetField(name, flags); + if (field != null) + { + field.SetValue(obj, value); + return true; + } + var property = type.GetProperty(name, flags); + if (property != null) + { + property.SetValue(obj, value); + return true; + } + return false; + } + + public static T GetOrAddComponent(this MonoBehaviour self) where T : Component + { + if (self.GetComponents().Length == 0) + { + return self.gameObject.AddComponent(); + } + else + { + return self.gameObject.GetComponents()[0]; + } + } + public static T SeekComponent(this MonoBehaviour self) where T : class + { + var results = self.gameObject.GetComponents(); + if (results.Length == 0) + return null; + return results[0]; + } + public static T GetOrAddComponent(this GameObject self) where T : Component + { + if (self.GetComponents().Length == 0) + { + return self.AddComponent(); + } + else + { + return self.GetComponents()[0]; + } + } + public static T SeekComponent(this GameObject self) where T : class + { + var results = self.GetComponents(); + if (results.Length == 0) + return null; + return results[0]; + } + + public static List SeekType(Predicate pr, IEnumerable assemblys = null, int findCount = -1) + { + List types = new List(); + if (assemblys == null) + assemblys = AppDomain.CurrentDomain.GetAssemblies(); + foreach (var assembly in assemblys) + { + foreach (var type in assembly.GetTypes()) + { + if (pr(type)) + types.Add(type); + if (types.Count == findCount) + return types; + } + } + return types; + } + + public static List GetMemberInfos(Type type, IEnumerable cutOffType = null, bool isGetNotPublic = false, bool isGetStatic = false) + { + Type current = type; + BindingFlags flags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly; + List result = new(); + if (isGetNotPublic) + flags |= BindingFlags.NonPublic; + if (isGetStatic) + flags |= BindingFlags.Static; + while ((cutOffType != null && !cutOffType.Contains(current)) && current != null) + { + result.AddRange(current.GetFields(flags)); + result.AddRange(current.GetProperties(flags)); + result.AddRange(current.GetMethods(flags)); + current = current.BaseType; + } + return result; + } + } + + [Serializable] + public class SALCheckException : Exception + { + public delegate bool Predicate(object val); + public Attribute attribute; + public SALCheckException(Attribute attribute) { this.attribute = attribute; } + public SALCheckException(Attribute attribute, string message) : base(message) { this.attribute = attribute; } + public SALCheckException(Attribute attribute, string message, Exception inner) : base(message, inner) { this.attribute = attribute; } + } + [System.AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)] + public class InAttribute : Attribute { } + [System.AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)] + public class OutAttribute : Attribute { } + [System.AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = true)] + public class OptAttribute : Attribute { } + [System.AttributeUsage(AttributeTargets.ReturnValue, Inherited = true, AllowMultiple = false)] + public class ReturnVirtualAttribute : Attribute { } + [System.AttributeUsage(AttributeTargets.ReturnValue, Inherited = true, AllowMultiple = false)] + public class ReturnMayNullAttribute : Attribute { } + [System.AttributeUsage(AttributeTargets.ReturnValue, Inherited = true, AllowMultiple = false)] + public class ReturnNotNullAttribute : Attribute { } + [System.AttributeUsage(AttributeTargets.ReturnValue, Inherited = true, AllowMultiple = false)] + public class ReturnSelfAttribute : Attribute { } + [System.AttributeUsage(AttributeTargets.ReturnValue, Inherited = true, AllowMultiple = false)] + public class ReturnNotSelfAttribute : Attribute { } +#if UNITY_2017_1_OR_NEWER + [System.AttributeUsage(AttributeTargets.Parameter | AttributeTargets.ReturnValue | + AttributeTargets.Field | AttributeTargets.Property, Inherited = true, AllowMultiple = false)] + public class IsInstantiatedAttribute : Attribute + { + public bool isInstantiated; + public IsInstantiatedAttribute(bool isInstantiated) + { + this.isInstantiated = isInstantiated; + } + } +#endif + [System.AttributeUsage(AttributeTargets.ReturnValue, Inherited = true, AllowMultiple = false)] + public class SucceedAttribute : Attribute + { + private SALCheckException.Predicate pr; + public SucceedAttribute([In] object succeed_when_return_value_is_equal_this_value_or_pr_is_return_true) + { + var prm = succeed_when_return_value_is_equal_this_value_or_pr_is_return_true.GetType().GetMethod("Invoke"); + if (prm != null && + prm.GetParameters().Length == 1 && + prm.ReturnType == typeof(bool)) + this.pr = (SALCheckException.Predicate)succeed_when_return_value_is_equal_this_value_or_pr_is_return_true; + else + this.pr = (object obj) => obj == succeed_when_return_value_is_equal_this_value_or_pr_is_return_true; + } + + public bool Check([In][Opt] object value) + { + if (this.pr(value)) + return true; + throw new SALCheckException(this, $"return value<{value.ToString()[..25]}...> is not expect"); + } + } + [System.AttributeUsage(AttributeTargets.ReturnValue, Inherited = true, AllowMultiple = false)] + public class NotSucceedAttribute : Attribute + { + private SALCheckException.Predicate pr; + public NotSucceedAttribute([In] object failed_when_return_value_is_equal_this_value_or_pr_is_return_true) + { + var prm = failed_when_return_value_is_equal_this_value_or_pr_is_return_true.GetType().GetMethod("Invoke"); + if (prm != null && + prm.GetParameters().Length == 1 && + prm.ReturnType == typeof(bool)) + this.pr = (SALCheckException.Predicate)failed_when_return_value_is_equal_this_value_or_pr_is_return_true; + else + this.pr = (object obj) => obj == failed_when_return_value_is_equal_this_value_or_pr_is_return_true; + } + + public bool Check([In][Opt] object value) + { + if (this.pr(value)) + throw new SALCheckException(this, $"return value<{value.ToString()[..25]}...> is not expect"); + return true; + } + } + [System.AttributeUsage(AttributeTargets.Method, Inherited = true, AllowMultiple = false)] + public class MethodReturnSelfAttribute : Attribute { } + [System.AttributeUsage(AttributeTargets.Method, Inherited = true, AllowMultiple = false)] + public class MethodReturnNotSelfAttribute : Attribute { } + [System.AttributeUsage(AttributeTargets.All, Inherited = true, AllowMultiple = true)] + public class WhenAttribute : Attribute + { + private SALCheckException.Predicate pr = null; + public readonly Type TypenAttribute = null; + /// + /// bool predicate(object)+typenAttribute + /// value+typenAttribute + /// + /// The value will been checked or predicate + /// Target Checker + public WhenAttribute([In] object control_value_or_predicate, [In] Type typenAttribute) + { + this.TypenAttribute = typenAttribute; + if (typenAttribute == typeof(OnlyNotNullModeAttribute)) + { + if (ConventionUtility.IsString(control_value_or_predicate)) + { + this.pr = (object obj) => + { + return new OnlyNotNullModeAttribute((string)control_value_or_predicate).Check(obj); + }; + return; + } + } + else if ( + typenAttribute.Name.EndsWith("SucceedAttribute") || + typenAttribute.Name.StartsWith("Return") + ) + { + return; + } + do + { + var prm = control_value_or_predicate.GetType().GetMethod("Invoke"); + if (prm != null && + prm.GetParameters().Length == 1 && + prm.ReturnType == typeof(bool)) + this.pr = (SALCheckException.Predicate)control_value_or_predicate; + else + this.pr = (object obj) => obj == control_value_or_predicate; + } while (false); + } + /// + /// do nothing + /// + /// + public WhenAttribute([In] string description) { } + protected WhenAttribute() { } + +#if UNITY_EDITOR + /// + /// The value is + /// is :member value is not null + /// Default:predicate(target) + /// + /// + /// +#endif + public virtual bool Check([In][Opt] object value) + { + if (TypenAttribute == typeof(OnlyNotNullModeAttribute)) + { + return pr(value); + } + else + { + if (pr == null) + //throw new SALCheckException(this, "you should not check at this"); + return true; + if (this.pr(value)) + return true; + return false; + } + } + + [System.AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, Inherited = true, AllowMultiple = true)] + public abstract class WhenMemberValueAttribute : WhenAttribute + { + public readonly string Name; + public readonly object Value; + protected object InjectGetValue(object target) + { + return ConventionUtility.SeekValue(target, Name, BindingFlags.NonPublic | BindingFlags.Public | + BindingFlags.Instance | BindingFlags.Static); + } + public override bool Check(object target) + { + throw new NotImplementedException(); + } + public WhenMemberValueAttribute(string Name, object value) + { + this.Name = Name; + this.Value = value; + } + } + [System.AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, Inherited = true, AllowMultiple = true)] + public class IsAttribute : WhenMemberValueAttribute + { + public override bool Check(object target) + { + if (this.Value is Type) + { + var targetValue = this.InjectGetValue(target); + if (targetValue == null) + return false; + else + return targetValue.GetType().IsSubclassOf(this.Value as Type); + } + if (this.Value != null) + return this.Value.Equals(this.InjectGetValue(target)); + var injectValue = this.InjectGetValue(target); + if (injectValue != null) + return injectValue.Equals(this.Value); + return injectValue == null && this.Value == null; + } + public IsAttribute(string Name, object value) : base(Name, value) { } + } + [System.AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, Inherited = true, AllowMultiple = true)] + public class NotAttribute : IsAttribute + { + public override bool Check(object target) + { + return !base.Check(target); + } + public NotAttribute(string Name, object value) : base(Name, value) { } + } + } + [System.AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = false)] + public class IgnoreAttribute : Attribute { } + [System.AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = false)] + public class ProjectContextLabelAttribute : Attribute + { + public enum ContextLabelType + { + Content, Resources, Setting + } + public static void DebugError(string mainName, string message, ContextLabelType type, UnityEngine.Object obj) + { + string labelname = type switch + { + ContextLabelType.Setting => "setting", + ContextLabelType.Resources => "resources", + ContextLabelType.Content => "content", + _ => "context-label" + }; + Debug.LogError($"{mainName} - {message} due to missing {labelname}.", obj); + } + } + [System.AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = false)] + public class SettingAttribute : ProjectContextLabelAttribute { } + [System.AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = false)] + public class ResourcesAttribute : ProjectContextLabelAttribute { } + [System.AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = false)] + public class ContentAttribute : ProjectContextLabelAttribute { } + [System.AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = false)] + public class OnlyPlayModeAttribute : Attribute { } + [System.AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = false)] + public class OnlyNotNullModeAttribute : Attribute + { + public string Name; + public bool Check(object target) + { + if (IsSelf()) + { +#if UNITY_2017_1_OR_NEWER + if (target is UnityEngine.Object && (target as UnityEngine.Object) == null) + return false; +#endif + return target != null; + } + var field = target.GetType().GetField(Name, BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + if (field != null) + { + object value = field.GetValue(target); + if (value == null) + return false; +#if UNITY_2017_1_OR_NEWER + if (value is UnityEngine.Object && (value as UnityEngine.Object) == null) + return false; +#endif + return true; + } + var property = target.GetType().GetProperty(Name, BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + if (property != null) + { + object value = property.GetValue(target); + if (value == null) + return false; +#if UNITY_2017_1_OR_NEWER + if (value is UnityEngine.Object && (value as UnityEngine.Object) == null) + return false; +#endif + return true; + } + return false; + } + public bool IsSelf() => Name == null || Name.Length == 0; + /// + /// binding to target field + /// + /// + public OnlyNotNullModeAttribute(string fieldName) { this.Name = fieldName; } + /// + /// binding to self + /// + public OnlyNotNullModeAttribute() { this.Name = null; } + } + [System.AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = false)] + public class HopeNotNullAttribute : Attribute + { + public bool Check(object target) + { + return target != null; + } + public HopeNotNullAttribute() { } + } + [System.AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | + AttributeTargets.Parameter | AttributeTargets.ReturnValue, + Inherited = false, AllowMultiple = false)] + public class PercentageAttribute : Attribute + { + public float min = 0, max = 100; + public PercentageAttribute([In] float min, [In] float max) + { + this.min = min; + this.max = max; + } + } + [System.AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | + AttributeTargets.Class | AttributeTargets.Class | + AttributeTargets.Parameter | AttributeTargets.ReturnValue | + AttributeTargets.Interface | AttributeTargets.GenericParameter, Inherited = false, AllowMultiple = false)] + public class ArgPackageAttribute : Attribute + { + public Type[] UsedFor; + public ArgPackageAttribute([In][Opt] params Type[] usedFor) + { + UsedFor = usedFor; + } + } + [System.AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = false)] + public class TODOAttribute : Attribute + { + public bool Check(object any) + { + throw new InvalidOperationException("TODO"); + throw new NotImplementedException(); + } + } + [System.AttributeUsage(AttributeTargets.All, Inherited = true, AllowMultiple = false)] + public class ImportantAttribute : Attribute + { + public string description; + + public ImportantAttribute(string description) + { + this.description = description; + } + public ImportantAttribute() { } + } + [System.AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] + public class DescriptionAttribute : Attribute + { + public string description; + public DescriptionAttribute(string description) + { + this.description = description; + } + } + [System.AttributeUsage(AttributeTargets.All, Inherited = true, AllowMultiple = true)] + public class TypeCheckAttribute : Attribute + { + public readonly Type[] typens; + public readonly string description; + + public TypeCheckAttribute(string description, params Type[] typens) + { + this.typens = typens; + this.description = description; + } + + public TypeCheckAttribute(params Type[] typens) : this("Type Check Failed: value is not sub class of " + + $"{string.Join(",", typens.ToList().ConvertAll(x => x.Name))}" + + ", current is ${type}", typens) + { + + } + + public bool Check(object target) + { + return target != null && + typens.Any(x => target.GetType().IsSubclassOf(x) || x.IsInterface && target.GetType().GetInterface(x.Name) != null); + } + } + + + public static partial class ConventionUtility + { +#if UNITY_EDITOR + [UnityEditor.MenuItem("Convention/InitExtensionEnv", priority = 100000)] +#endif + public static void InitExtensionEnv() + { + UnityEngine.Application.quitting += () => CoroutineStarter = null; + + GlobalConfig.InitExtensionEnv(); + + ES3Plugin.InitExtensionEnv(); + } + + public static int MainThreadID { get; private set; } + public static bool CurrentThreadIsMainThread() + { + return MainThreadID == Thread.CurrentThread.ManagedThreadId; + } + + private static CoroutineMonoStarterUtil CoroutineStarter; + + private class CoroutineMonoStarterUtil : MonoBehaviour + { + private void Update() + { + MainThreadID = Thread.CurrentThread.ManagedThreadId; + } + + private void OnDestroy() + { + CoroutineStarter = null; + } + } + public static Coroutine StartCoroutine(IEnumerator coroutine) + { + if (CoroutineStarter == null) + { + CoroutineStarter = new GameObject($"{nameof(ConventionUtility)}-{nameof(CoroutineStarter)}").AddComponent(); + } + return CoroutineStarter.StartCoroutine(coroutine); + } + public static void CloseCoroutine(Coroutine coroutine) + { + CoroutineStarter.StopCoroutine(coroutine); + } + public static void StopAllCoroutine() + { + CoroutineStarter.StopAllCoroutines(); + } + + public class ActionStepCoroutineWrapper + { + private List> steps = new(); + public ActionStepCoroutineWrapper Update(Action action) + { + steps.Add(new(null, action)); + return this; + } + public ActionStepCoroutineWrapper Wait(float time, Action action) + { + steps.Add(new(new WaitForSeconds(time), action)); + return this; + } + public ActionStepCoroutineWrapper FixedUpdate(Action action) + { + steps.Add(new(new WaitForFixedUpdate(), action)); + return this; + } + public ActionStepCoroutineWrapper Next(Action action) + { + steps.Add(new(new WaitForEndOfFrame(), action)); + return this; + } + private static IEnumerator Execute(List> steps) + { + foreach (var (waiting, action) in steps) + { + action(); + yield return waiting; + } + } + ~ActionStepCoroutineWrapper() + { + this.Invoke(); + } + public void Invoke() + { + StartCoroutine(Execute(new List>(steps))); + steps.Clear(); + } + } + /// + /// ��Ҫ���շ���ֵ, �����ӳٵ�Wrapper���������ִ������ + /// + /// + [return: ReturnNotSelf] + public static ActionStepCoroutineWrapper CreateSteps() => new(); + + public static bool IsNumber([In] object data) + { + if (data == null) return false; + var type = data.GetType(); + return IsNumber(type); + } + public static bool IsString([In] object data) + { + if (data == null) return false; + var type = data.GetType(); + return IsString(type); + } + public static bool IsBinary([In] object data) + { + if (data == null) return false; + var type = data.GetType(); + return IsBinary(type); + } + public static bool IsArray([In] object data) + { + if (data == null) return false; + var type = data.GetType(); + return IsArray(type); + } + public static bool IsBool([In] object data) + { + if (data == null) return false; + return IsBool(data.GetType()); + } + + public static bool IsNumber([In] Type type) + { + return + type == typeof(double) || + type == typeof(float) || + type == typeof(int) || + type == typeof(long) || + type == typeof(sbyte) || + type == typeof(short) || + type == typeof(ushort) || + type == typeof(uint) || + type == typeof(ulong) || + type == typeof(char); + } + public static bool IsString([In] Type type) + { + return type == typeof(string) || type == typeof(char[]); + } + public static bool IsBinary([In] Type type) + { + return + type == typeof(byte) || + type == typeof(sbyte) || + type == typeof(byte[]) || + type == typeof(sbyte[]); + } + public static bool IsArray([In] Type type) + { + return type.IsArray; + } + public static bool IsBool([In] Type type) + { + return type == typeof(bool); + } + public static bool IsEnum([In] Type type) + { + return type.IsEnum; + } + public static bool IsImage([In] Type type) + { + return type.IsSubclassOf(typeof(Texture)) || type == typeof(Sprite); + } + + public static bool HasCustomAttribute([In] MemberInfo member, [In] IEnumerable attrs) + { + foreach (var attr in attrs) + { + if (member.GetCustomAttribute(attr, true) != null) + return true; + } + return false; + } + [return: ReturnMayNull] + public static Type GetMemberValueType([In] MemberInfo member) + { + if (member is FieldInfo field) + { + return field.FieldType; + } + else if (member is PropertyInfo property) + { + return property.PropertyType; + } + return null; + } + public static bool GetMemberValueType([In] MemberInfo member, [Out] out Type type) + { + if (member is FieldInfo field) + { + type = field.FieldType; + return true; + } + else if (member is PropertyInfo property) + { + type = property.PropertyType; + return true; + } + type = null; + return false; + } + public static void PushValue([In] object target, [In][Opt, When("If you sure")] object value, [In] MemberInfo info) + { + if (info is FieldInfo field) + { + if (value.GetType().IsSubclassOf(field.FieldType)) + field.SetValue(target, value); + else + { + field.SetValue(target, field.FieldType.GetMethod(nameof(float.Parse)).Invoke(target, new object[] { value })); + } + } + else if (info is PropertyInfo property) + { + property.SetValue(target, value); + } + else + { + throw new InvalidOperationException("info is unsupport"); + } + } + public static object SeekValue([In] object target, [In] MemberInfo info) + { + if (info is FieldInfo field) + { + return field.GetValue(target); + } + else if (info is PropertyInfo property) + { + return property.GetValue(target); + } + else + { + throw new InvalidOperationException("info is unsupport"); + } + } + public static bool TrySeekValue([In] object target, [In] MemberInfo info, [Out] out object value) + { + if (info is FieldInfo field) + { + value = field.GetValue(target); + return true; + } + else if (info is PropertyInfo property) + { + value = property.GetValue(target); + return true; + } + value = null; + return false; + } + + public static List SeekMemberInfo( + [In] object target, + [In, Opt] IEnumerable attrs, [In, Opt] IEnumerable types, + [In, Opt] Type untilBase = null + ) + { + Type _CurType = target.GetType(); + List result = new(); + result.AddRange(_CurType.GetMembers(BindingFlags.Public | BindingFlags.Instance)); + while (_CurType != null && _CurType != typeof(object) && _CurType != untilBase) + { + result.AddRange( + from info in _CurType.GetMembers(BindingFlags.NonPublic | BindingFlags.Instance) + where attrs == null || HasCustomAttribute(info, attrs) + where types == null || (GetMemberValueType(info, out var type) && types.Contains(type)) + select info + ); + _CurType = _CurType.BaseType; + } + return result; + } + public static List SeekMemberInfo([In] object target, IEnumerable names, BindingFlags flags = BindingFlags.Default) + { + Type _CurType = target.GetType(); + List result = _CurType.GetMembers(flags).ToList(); + HashSet nameSet = names.ToHashSet(); + result.RemoveAll(x => nameSet.Contains(x.Name) == false); + return result; + } + public static object InvokeMember([In] MemberInfo member, [In] object target, params object[] parameters) + { + if (member is MethodInfo method) + { + return method.Invoke(target, parameters); + } + return null; + } + public static bool TryInvokeMember([In] MemberInfo member, object target, out object returnValue, params object[] parameters) + { + returnValue = null; + if (member is MethodInfo method) + { + returnValue = method.Invoke(target, parameters); + return true; + } + else return false; + } + } + +#if UNITY_2017_1_OR_NEWER + namespace Internal + { + public interface IRectTransform + { + UnityEngine.RectTransform rectTransform { get; } + } + } +#endif + + public static partial class ConventionUtility + { + public static UnityEvent WrapperAction2Event(params UnityAction[] actions) + { + var result = new UnityEvent(); + foreach (var action in actions) + { + result.AddListener(action); + } + return result; + } + public static UnityEvent WrapperAction2Event(params UnityAction[] actions) + { + var result = new UnityEvent(); + foreach (var action in actions) + { + result.AddListener(action); + } + return result; + } + public static UnityEvent WrapperAction2Event(params UnityAction[] actions) + { + var result = new UnityEvent(); + foreach (var action in actions) + { + result.AddListener(action); + } + return result; + } + public static UnityEvent WrapperAction2Event(params UnityAction[] actions) + { + var result = new UnityEvent(); + foreach (var action in actions) + { + result.AddListener(action); + } + return result; + } + public static UnityEvent WrapperAction2Event(params UnityAction[] actions) + { + var result = new UnityEvent(); + foreach (var action in actions) + { + result.AddListener(action); + } + return result; + } + } +} \ No newline at end of file diff --git a/Convention/[Visual].meta b/Convention/[Visual].meta new file mode 100644 index 0000000..9d45cc2 --- /dev/null +++ b/Convention/[Visual].meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 21db3072261b86b4398d8bb8c0f8d85f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/Operater.meta b/Convention/[Visual]/Operater.meta new file mode 100644 index 0000000..917eb7f --- /dev/null +++ b/Convention/[Visual]/Operater.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e2f2a62dfceb71643a8a2cd7cbdf42b4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/Operater/BaseBeginDragBehaviour.cs b/Convention/[Visual]/Operater/BaseBeginDragBehaviour.cs new file mode 100644 index 0000000..d7f14fd --- /dev/null +++ b/Convention/[Visual]/Operater/BaseBeginDragBehaviour.cs @@ -0,0 +1,16 @@ +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.EventSystems; + +namespace Convention.WindowsUI +{ + public class BaseBeginDragBehaviour : MonoBehaviour, IBeginDragHandler, IBehaviourOperator + { + public UnityEvent OnBeginDragEvent; + + public void OnBeginDrag(PointerEventData eventData) + { + OnBeginDragEvent?.Invoke(eventData); + } + } +} diff --git a/Convention/[Visual]/Operater/BaseBeginDragBehaviour.cs.meta b/Convention/[Visual]/Operater/BaseBeginDragBehaviour.cs.meta new file mode 100644 index 0000000..a76af00 --- /dev/null +++ b/Convention/[Visual]/Operater/BaseBeginDragBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 521ce1a0929016d4e9e94fa46517292e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/Operater/BaseCancelBehaviour.cs b/Convention/[Visual]/Operater/BaseCancelBehaviour.cs new file mode 100644 index 0000000..7433ac5 --- /dev/null +++ b/Convention/[Visual]/Operater/BaseCancelBehaviour.cs @@ -0,0 +1,16 @@ +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.EventSystems; + +namespace Convention.WindowsUI +{ + public class BaseCancelBehaviour : MonoBehaviour, ICancelHandler, IBehaviourOperator + { + public UnityEvent OnCancelEvent; + + public void OnCancel(BaseEventData eventData) + { + OnCancelEvent?.Invoke(eventData); + } + } +} diff --git a/Convention/[Visual]/Operater/BaseCancelBehaviour.cs.meta b/Convention/[Visual]/Operater/BaseCancelBehaviour.cs.meta new file mode 100644 index 0000000..22b2022 --- /dev/null +++ b/Convention/[Visual]/Operater/BaseCancelBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2212d17ad10dca444b7bb1c5fa038b29 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/Operater/BaseDeselectBehaviour.cs b/Convention/[Visual]/Operater/BaseDeselectBehaviour.cs new file mode 100644 index 0000000..2e6df5e --- /dev/null +++ b/Convention/[Visual]/Operater/BaseDeselectBehaviour.cs @@ -0,0 +1,16 @@ +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.EventSystems; + +namespace Convention.WindowsUI +{ + public class BaseDeselectBehaviour : MonoBehaviour, IDeselectHandler, IBehaviourOperator + { + public UnityEvent OnDeselectEvent; + + public void OnDeselect(BaseEventData eventData) + { + OnDeselectEvent?.Invoke(eventData); + } + } +} diff --git a/Convention/[Visual]/Operater/BaseDeselectBehaviour.cs.meta b/Convention/[Visual]/Operater/BaseDeselectBehaviour.cs.meta new file mode 100644 index 0000000..c30f3ea --- /dev/null +++ b/Convention/[Visual]/Operater/BaseDeselectBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7a0f3a17622ff7f4db3d6b72311ca7b6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/Operater/BaseDragBehaviour.cs b/Convention/[Visual]/Operater/BaseDragBehaviour.cs new file mode 100644 index 0000000..e20f2ab --- /dev/null +++ b/Convention/[Visual]/Operater/BaseDragBehaviour.cs @@ -0,0 +1,16 @@ +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.EventSystems; + +namespace Convention.WindowsUI +{ + public class BaseDragBehaviour : MonoBehaviour, IDragHandler, IBehaviourOperator + { + public UnityEvent OnDragEvent; + + public void OnDrag(PointerEventData eventData) + { + OnDragEvent?.Invoke(eventData); + } + } +} diff --git a/Convention/[Visual]/Operater/BaseDragBehaviour.cs.meta b/Convention/[Visual]/Operater/BaseDragBehaviour.cs.meta new file mode 100644 index 0000000..3798b8f --- /dev/null +++ b/Convention/[Visual]/Operater/BaseDragBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e031d99c1b1405843a30171422e8ba6b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/Operater/BaseDropBehaviour.cs b/Convention/[Visual]/Operater/BaseDropBehaviour.cs new file mode 100644 index 0000000..e745b86 --- /dev/null +++ b/Convention/[Visual]/Operater/BaseDropBehaviour.cs @@ -0,0 +1,16 @@ +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.EventSystems; + +namespace Convention.WindowsUI +{ + public class BaseDropBehaviour : MonoBehaviour, IDropHandler, IBehaviourOperator + { + public UnityEvent OnDropEvent; + + public void OnDrop(PointerEventData eventData) + { + OnDropEvent?.Invoke(eventData); + } + } +} diff --git a/Convention/[Visual]/Operater/BaseDropBehaviour.cs.meta b/Convention/[Visual]/Operater/BaseDropBehaviour.cs.meta new file mode 100644 index 0000000..0c0a3f4 --- /dev/null +++ b/Convention/[Visual]/Operater/BaseDropBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d2ae05f07a6ad5a489e2b2f9c1d78d9c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/Operater/BaseEndDragBehaviour.cs b/Convention/[Visual]/Operater/BaseEndDragBehaviour.cs new file mode 100644 index 0000000..d4df52c --- /dev/null +++ b/Convention/[Visual]/Operater/BaseEndDragBehaviour.cs @@ -0,0 +1,16 @@ +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.EventSystems; + +namespace Convention.WindowsUI +{ + public class BaseEndDragBehaviour : MonoBehaviour, IEndDragHandler, IBehaviourOperator + { + public UnityEvent OnEndDragEvent; + + public void OnEndDrag(PointerEventData eventData) + { + OnEndDragEvent?.Invoke(eventData); + } + } +} diff --git a/Convention/[Visual]/Operater/BaseEndDragBehaviour.cs.meta b/Convention/[Visual]/Operater/BaseEndDragBehaviour.cs.meta new file mode 100644 index 0000000..98b43f7 --- /dev/null +++ b/Convention/[Visual]/Operater/BaseEndDragBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bdee6774c0841f84d9b54844ff020564 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/Operater/BaseInitializePotentialDragBehaviour.cs b/Convention/[Visual]/Operater/BaseInitializePotentialDragBehaviour.cs new file mode 100644 index 0000000..a5803c7 --- /dev/null +++ b/Convention/[Visual]/Operater/BaseInitializePotentialDragBehaviour.cs @@ -0,0 +1,16 @@ +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.EventSystems; + +namespace Convention.WindowsUI +{ + public class BaseInitializePotentialDragBehaviour : MonoBehaviour, IInitializePotentialDragHandler, IBehaviourOperator + { + public UnityEvent OnInitializePotentialDragEvent; + + public void OnInitializePotentialDrag(PointerEventData eventData) + { + OnInitializePotentialDragEvent?.Invoke(eventData); + } + } +} diff --git a/Convention/[Visual]/Operater/BaseInitializePotentialDragBehaviour.cs.meta b/Convention/[Visual]/Operater/BaseInitializePotentialDragBehaviour.cs.meta new file mode 100644 index 0000000..0b35351 --- /dev/null +++ b/Convention/[Visual]/Operater/BaseInitializePotentialDragBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4b0477e219558a5458fbd5041b99fbba +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/Operater/BaseMoveBehaviour.cs b/Convention/[Visual]/Operater/BaseMoveBehaviour.cs new file mode 100644 index 0000000..941df90 --- /dev/null +++ b/Convention/[Visual]/Operater/BaseMoveBehaviour.cs @@ -0,0 +1,16 @@ +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.EventSystems; + +namespace Convention.WindowsUI +{ + public class BaseMoveBehaviour : MonoBehaviour, IMoveHandler, IBehaviourOperator + { + public UnityEvent OnMoveEvent; + + public void OnMove(AxisEventData eventData) + { + OnMoveEvent?.Invoke(eventData); + } + } +} diff --git a/Convention/[Visual]/Operater/BaseMoveBehaviour.cs.meta b/Convention/[Visual]/Operater/BaseMoveBehaviour.cs.meta new file mode 100644 index 0000000..4f9a6e8 --- /dev/null +++ b/Convention/[Visual]/Operater/BaseMoveBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 65e71cc97af54d74e86e85f52b8fee64 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/Operater/BasePointerClickBehaviour.cs b/Convention/[Visual]/Operater/BasePointerClickBehaviour.cs new file mode 100644 index 0000000..7d75abd --- /dev/null +++ b/Convention/[Visual]/Operater/BasePointerClickBehaviour.cs @@ -0,0 +1,16 @@ +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.EventSystems; + +namespace Convention.WindowsUI +{ + public class BasePointerClickBehaviour : MonoBehaviour, IPointerClickHandler, IBehaviourOperator + { + public UnityEvent OnPointerClickEvent; + + public void OnPointerClick(PointerEventData eventData) + { + OnPointerClickEvent?.Invoke(eventData); + } + } +} diff --git a/Convention/[Visual]/Operater/BasePointerClickBehaviour.cs.meta b/Convention/[Visual]/Operater/BasePointerClickBehaviour.cs.meta new file mode 100644 index 0000000..461c36c --- /dev/null +++ b/Convention/[Visual]/Operater/BasePointerClickBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b836729fafa81c940ad766b2b7a39ffe +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/Operater/BasePointerDownBehaviour.cs b/Convention/[Visual]/Operater/BasePointerDownBehaviour.cs new file mode 100644 index 0000000..a71c7cc --- /dev/null +++ b/Convention/[Visual]/Operater/BasePointerDownBehaviour.cs @@ -0,0 +1,16 @@ +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.EventSystems; + +namespace Convention.WindowsUI +{ + public class BasePointerDownBehaviour : MonoBehaviour, IPointerDownHandler, IBehaviourOperator + { + public UnityEvent OnPointerDownEvent; + + public void OnPointerDown(PointerEventData eventData) + { + OnPointerDownEvent?.Invoke(eventData); + } + } +} diff --git a/Convention/[Visual]/Operater/BasePointerDownBehaviour.cs.meta b/Convention/[Visual]/Operater/BasePointerDownBehaviour.cs.meta new file mode 100644 index 0000000..3bfc2b4 --- /dev/null +++ b/Convention/[Visual]/Operater/BasePointerDownBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 21606bade6bda96479188aa775bb7958 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/Operater/BasePointerEnterBehaviour.cs b/Convention/[Visual]/Operater/BasePointerEnterBehaviour.cs new file mode 100644 index 0000000..4f99dc4 --- /dev/null +++ b/Convention/[Visual]/Operater/BasePointerEnterBehaviour.cs @@ -0,0 +1,16 @@ +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.EventSystems; + +namespace Convention.WindowsUI +{ + public class BasePointerEnterBehaviour : MonoBehaviour, IPointerEnterHandler, IBehaviourOperator + { + public UnityEvent OnPointerEnterEvent; + + public void OnPointerEnter(PointerEventData eventData) + { + OnPointerEnterEvent?.Invoke(eventData); + } + } +} diff --git a/Convention/[Visual]/Operater/BasePointerEnterBehaviour.cs.meta b/Convention/[Visual]/Operater/BasePointerEnterBehaviour.cs.meta new file mode 100644 index 0000000..685dc26 --- /dev/null +++ b/Convention/[Visual]/Operater/BasePointerEnterBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 213f8197d2e780a4eb37503ae30823ce +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/Operater/BasePointerExitBehaviour.cs b/Convention/[Visual]/Operater/BasePointerExitBehaviour.cs new file mode 100644 index 0000000..f398b9e --- /dev/null +++ b/Convention/[Visual]/Operater/BasePointerExitBehaviour.cs @@ -0,0 +1,16 @@ +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.EventSystems; + +namespace Convention.WindowsUI +{ + public class BasePointerExitBehaviour : MonoBehaviour, IPointerExitHandler, IBehaviourOperator + { + public UnityEvent OnPointerExitEvent; + + public void OnPointerExit(PointerEventData eventData) + { + OnPointerExitEvent?.Invoke(eventData); + } + } +} diff --git a/Convention/[Visual]/Operater/BasePointerExitBehaviour.cs.meta b/Convention/[Visual]/Operater/BasePointerExitBehaviour.cs.meta new file mode 100644 index 0000000..ba2ae1f --- /dev/null +++ b/Convention/[Visual]/Operater/BasePointerExitBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5977b725805788d429efc1ae02814fe4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/Operater/BasePointerUpBehaviour.cs b/Convention/[Visual]/Operater/BasePointerUpBehaviour.cs new file mode 100644 index 0000000..11d7e5a --- /dev/null +++ b/Convention/[Visual]/Operater/BasePointerUpBehaviour.cs @@ -0,0 +1,16 @@ +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.EventSystems; + +namespace Convention.WindowsUI +{ + public class BasePointerUpBehaviour : MonoBehaviour, IPointerUpHandler, IBehaviourOperator + { + public UnityEvent OnPointerUpEvent; + + public void OnPointerUp(PointerEventData eventData) + { + OnPointerUpEvent?.Invoke(eventData); + } + } +} diff --git a/Convention/[Visual]/Operater/BasePointerUpBehaviour.cs.meta b/Convention/[Visual]/Operater/BasePointerUpBehaviour.cs.meta new file mode 100644 index 0000000..d1766af --- /dev/null +++ b/Convention/[Visual]/Operater/BasePointerUpBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e0aa7d709dfba11448935fe27cf70245 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/Operater/BaseScrollBehaviour.cs b/Convention/[Visual]/Operater/BaseScrollBehaviour.cs new file mode 100644 index 0000000..2a8fd1a --- /dev/null +++ b/Convention/[Visual]/Operater/BaseScrollBehaviour.cs @@ -0,0 +1,16 @@ +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.EventSystems; + +namespace Convention.WindowsUI +{ + public class BaseScrollBehaviour : MonoBehaviour, IScrollHandler, IBehaviourOperator + { + public UnityEvent OnScrollEvent; + + public void OnScroll(PointerEventData eventData) + { + OnScrollEvent?.Invoke(eventData); + } + } +} diff --git a/Convention/[Visual]/Operater/BaseScrollBehaviour.cs.meta b/Convention/[Visual]/Operater/BaseScrollBehaviour.cs.meta new file mode 100644 index 0000000..b72ff88 --- /dev/null +++ b/Convention/[Visual]/Operater/BaseScrollBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8df8288fe7377214ca4d71e78161d64a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/Operater/BaseSelectBehaviour.cs b/Convention/[Visual]/Operater/BaseSelectBehaviour.cs new file mode 100644 index 0000000..bc386ad --- /dev/null +++ b/Convention/[Visual]/Operater/BaseSelectBehaviour.cs @@ -0,0 +1,16 @@ +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.EventSystems; + +namespace Convention.WindowsUI +{ + public class BaseSelectBehaviour : MonoBehaviour, ISelectHandler, IBehaviourOperator + { + public UnityEvent OnSelectEvent; + + public void OnSelect(BaseEventData eventData) + { + OnSelectEvent?.Invoke(eventData); + } + } +} diff --git a/Convention/[Visual]/Operater/BaseSelectBehaviour.cs.meta b/Convention/[Visual]/Operater/BaseSelectBehaviour.cs.meta new file mode 100644 index 0000000..00d00c0 --- /dev/null +++ b/Convention/[Visual]/Operater/BaseSelectBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8d7ef3c266a619540a243e4cd07206fc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/Operater/BaseSubmitBehaviour.cs b/Convention/[Visual]/Operater/BaseSubmitBehaviour.cs new file mode 100644 index 0000000..e7e4f0b --- /dev/null +++ b/Convention/[Visual]/Operater/BaseSubmitBehaviour.cs @@ -0,0 +1,16 @@ +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.EventSystems; + +namespace Convention.WindowsUI +{ + public class BaseSubmitBehaviour : MonoBehaviour, ISubmitHandler, IBehaviourOperator + { + public UnityEvent OnSubmitEvent; + + public void OnSubmit(BaseEventData eventData) + { + OnSubmitEvent?.Invoke(eventData); + } + } +} diff --git a/Convention/[Visual]/Operater/BaseSubmitBehaviour.cs.meta b/Convention/[Visual]/Operater/BaseSubmitBehaviour.cs.meta new file mode 100644 index 0000000..b6411ed --- /dev/null +++ b/Convention/[Visual]/Operater/BaseSubmitBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1f7528746466caa4aa60a67fdabd3f90 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/Operater/BaseUpdateSelectedBehaviour.cs b/Convention/[Visual]/Operater/BaseUpdateSelectedBehaviour.cs new file mode 100644 index 0000000..29bac71 --- /dev/null +++ b/Convention/[Visual]/Operater/BaseUpdateSelectedBehaviour.cs @@ -0,0 +1,16 @@ +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.EventSystems; + +namespace Convention.WindowsUI +{ + public class BaseUpdateSelectedBehaviour : MonoBehaviour, IUpdateSelectedHandler, IBehaviourOperator + { + public UnityEvent OnUpdateSelectedEvent; + + public void OnUpdateSelected(BaseEventData eventData) + { + OnUpdateSelectedEvent?.Invoke(eventData); + } + } +} diff --git a/Convention/[Visual]/Operater/BaseUpdateSelectedBehaviour.cs.meta b/Convention/[Visual]/Operater/BaseUpdateSelectedBehaviour.cs.meta new file mode 100644 index 0000000..c5f1968 --- /dev/null +++ b/Convention/[Visual]/Operater/BaseUpdateSelectedBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 331cf060da6669342b467554dd8b4493 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/Operater/DragBehaviour.cs b/Convention/[Visual]/Operater/DragBehaviour.cs new file mode 100644 index 0000000..8c93da9 --- /dev/null +++ b/Convention/[Visual]/Operater/DragBehaviour.cs @@ -0,0 +1,117 @@ +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Convention.WindowsUI +{ + public class DragBehaviour : WindowsComponent + { + [SerializeField, Resources] private BehaviourContextManager Context = null; + public BehaviourContextManager GetBehaviourContext() + { + if (Context == null) + Context = this.GetOrAddComponent(); + return Context; + } + public BehaviourContextManager DragBehaviourContext + { + get + { + if (Context == null) + Context = this.GetOrAddComponent(); + return Context; + } + } + + [Setting] public bool isCanDrag = true; + + public void SetDragAble(bool isCanDrag) + { + this.isCanDrag = isCanDrag; + } + + public void Init([In, Opt] RectTransform DragObjectInternal, [In, Opt] RectTransform DragAreaInternal) + { + if (DragObjectInternal != null) + this.DragObjectInternal = DragObjectInternal; + else if (this.DragObjectInternal == null) + this.DragObjectInternal = rectTransform; + if (DragAreaInternal != null) + this.DragAreaInternal = DragAreaInternal; + else if (this.DragAreaInternal == null) + this.DragAreaInternal = rectTransform.parent as RectTransform; + + DragBehaviourContext.OnBeginDragEvent ??= new(); + DragBehaviourContext.OnDragEvent ??= new(); + + DragBehaviourContext.OnBeginDragEvent.RemoveListener(this.OnBeginDrag); + DragBehaviourContext.OnBeginDragEvent.AddListener(this.OnBeginDrag); + DragBehaviourContext.OnDragEvent.RemoveListener(this.OnDrag); + DragBehaviourContext.OnDragEvent.AddListener(this.OnDrag); + DragBehaviourContext.locationValid = IsRaycastLocationValid; + } + + [Setting] public bool IsAutoInit = true; + private void Start() + { + Init(null, null); + } + + private void Reset() + { + isCanDrag = true; + DragObjectInternal = rectTransform; + } + + + [Setting] public bool topOnClick = true; + + [Content, Ignore, OnlyPlayMode, SerializeField] private Vector2 originalLocalPointerPosition; + [Content, Ignore, OnlyPlayMode, SerializeField] private Vector3 originalPanelLocalPosition; + + [Resources, SerializeField] private RectTransform DragObjectInternal; + + [Resources, SerializeField, WhenAttribute.Not(nameof(DragObjectInternal), null)] private RectTransform DragAreaInternal; + + public void OnBeginDrag(PointerEventData data) + { + if (!isCanDrag) return; + originalPanelLocalPosition = DragObjectInternal.localPosition; + RectTransformUtility.ScreenPointToLocalPointInRectangle(DragAreaInternal, data.position, data.pressEventCamera, out originalLocalPointerPosition); + gameObject.transform.SetAsLastSibling(); + + if (topOnClick == true) + DragObjectInternal.SetAsLastSibling(); + } + + public void OnDrag(PointerEventData data) + { + if (!isCanDrag) return; + Vector2 localPointerPosition; + if (RectTransformUtility.ScreenPointToLocalPointInRectangle(DragAreaInternal, data.position, data.pressEventCamera, out localPointerPosition)) + { + Vector3 offsetToOriginal = localPointerPosition - originalLocalPointerPosition; + DragObjectInternal.localPosition = originalPanelLocalPosition + offsetToOriginal; + } + + ClampToArea(); + } + + private void ClampToArea() + { + Vector3 pos = DragObjectInternal.localPosition; + + Vector3 minPosition = DragAreaInternal.rect.min - DragObjectInternal.rect.min; + Vector3 maxPosition = DragAreaInternal.rect.max - DragObjectInternal.rect.max; + + pos.x = Mathf.Clamp(DragObjectInternal.localPosition.x, minPosition.x, maxPosition.x); + pos.y = Mathf.Clamp(DragObjectInternal.localPosition.y, minPosition.y, maxPosition.y); + + DragObjectInternal.localPosition = pos; + } + + public bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera) + { + return isCanDrag || transform.childCount != 0; + } + } +} diff --git a/Convention/[Visual]/Operater/DragBehaviour.cs.meta b/Convention/[Visual]/Operater/DragBehaviour.cs.meta new file mode 100644 index 0000000..304889d --- /dev/null +++ b/Convention/[Visual]/Operater/DragBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c163c8a7285b54c4383a987f1d42065b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/UIComponent.meta b/Convention/[Visual]/UIComponent.meta new file mode 100644 index 0000000..9106b32 --- /dev/null +++ b/Convention/[Visual]/UIComponent.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 84a533f8e4805914580808722555eb7a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/UIComponent/BaseWindowBar.cs b/Convention/[Visual]/UIComponent/BaseWindowBar.cs new file mode 100644 index 0000000..6eafe1f --- /dev/null +++ b/Convention/[Visual]/UIComponent/BaseWindowBar.cs @@ -0,0 +1,276 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; +using System; + +namespace Convention.WindowsUI +{ + public class BaseWindowBar : WindowsComponent + { + // ----------------- + + private bool use_VerticalLayoutGroup => layoutGroupType == LayoutGroupType.VerticalLayoutGroup && verticalLayoutGroup; + private bool use_HorizontalLayoutGroup => layoutGroupType == LayoutGroupType.HorizontalLayoutGroup && horizontalLayoutGroup; + private bool use_GridLayoutGroup => layoutGroupType == LayoutGroupType.GridLayoutGroup && gridLayoutGroup; + + // ----------------- + + [Setting] public bool IsMaxInTop = true; + [Setting] public bool IsMinInButtm = true; + + public bool hasLayoutGroup => layoutGroupType != LayoutGroupType.None; + + [Resources, Setting, HopeNotNull] public SO.Windows WindowConfig; + [Resources, SerializeField, HopeNotNull] private RectTransform BarPlane; + [Resources, SerializeField, HopeNotNull] private WindowManager m_WindowManager; + [Resources, HopeNotNull] public WindowUIModule ButtonPrefab; + + [Content, OnlyPlayMode] + public void MinimizeWindow() + { + if (m_WindowManager) + { + if (IsMinInButtm) + m_WindowManager.transform.SetAsFirstSibling(); + m_WindowManager.WindowPlane.ExitMaximizeWindowMode(); + } + } + [Content, OnlyPlayMode] + public void MaximizeWindow() + { + if (m_WindowManager) + { + m_WindowManager.WindowPlane.MaximizeWindow(); + if (IsMaxInTop) + m_WindowManager.transform.SetAsLastSibling(); + } + } + [Content, OnlyPlayMode] + public void CloseWindow() + { + if (m_WindowManager) + { + m_WindowManager.CloseWindow(); + } + } + + public enum LayoutGroupType + { + VerticalLayoutGroup, + HorizontalLayoutGroup, + GridLayoutGroup, + None + } + [Setting] public LayoutGroupType layoutGroupType = LayoutGroupType.VerticalLayoutGroup; + [Resources, Setting, SerializeField, Header("Vertical Layout Group Setting")] + [HopeNotNull, WhenAttribute.Is(nameof(layoutGroupType), LayoutGroupType.VerticalLayoutGroup)] + private VerticalLayoutGroup verticalLayoutGroup; + [Resources, Setting, SerializeField, Header("Horizontal Layout Group Setting")] + [HopeNotNull, WhenAttribute.Is(nameof(layoutGroupType), LayoutGroupType.HorizontalLayoutGroup)] + private HorizontalLayoutGroup horizontalLayoutGroup; + [Resources, Setting, SerializeField, Header("Grid Layout Group")] + [HopeNotNull, WhenAttribute.Is(nameof(layoutGroupType), LayoutGroupType.GridLayoutGroup)] + private GridLayoutGroup gridLayoutGroup; + + public void Reset() + { + WindowConfig = Resources.Load(SO.Windows.GlobalWindowsConfig); + BarPlane = rectTransform; + ResetWindowManager(); + ButtonPrefab = WindowConfig.GetWindowsUI(nameof(ModernUIButton)) as WindowUIModule; + layoutGroupType = LayoutGroupType.HorizontalLayoutGroup; + ResetLayoutGroups(false); + } + + private void ResetLayoutGroups(bool isDestroy) + { + if (verticalLayoutGroup == null) + verticalLayoutGroup = BarPlane.GetComponent(); + if (horizontalLayoutGroup == null) + horizontalLayoutGroup = BarPlane.GetComponent(); + if (gridLayoutGroup == null) + gridLayoutGroup = BarPlane.GetComponent(); + if (!isDestroy) + return; + if (verticalLayoutGroup && layoutGroupType != LayoutGroupType.VerticalLayoutGroup) + Destroy(verticalLayoutGroup); + if (horizontalLayoutGroup && layoutGroupType != LayoutGroupType.HorizontalLayoutGroup) + Destroy(horizontalLayoutGroup); + if (gridLayoutGroup && layoutGroupType != LayoutGroupType.GridLayoutGroup) + Destroy(gridLayoutGroup); + } + private void ResetWindowManager() + { + m_WindowManager = null; + for (Transform item = transform; m_WindowManager == null && item != null; item = item.parent) + { + m_WindowManager = item.gameObject.GetComponent(); + } + } + + private void Start() + { + if (BarPlane == null) + BarPlane = rectTransform; + if (m_WindowManager == null) + { + ResetWindowManager(); + } + ResetLayoutGroups(true); + } + + private IButton InstantiateButton() + { + return Instantiate(ButtonPrefab, BarPlane.transform).GetComponents()[0]; + } + + [Serializable] + public class RegisteredButtonWrapper + { + public readonly BaseWindowBar WindowBar; + public IButton button; + public WindowUIModule buttonModule; + public RegisteredButtonWrapper([In] BaseWindowBar parentBar, [In] IButton button) + { + WindowBar = parentBar; + this.button = button; + buttonModule = button as WindowUIModule; + } + public virtual void Disable() + { + if (buttonModule) + { + buttonModule.gameObject.SetActive(false); + if (WindowBar.useGUILayout) + { + LayoutRebuilder.ForceRebuildLayoutImmediate(WindowBar.BarPlane); + } + } + } + public virtual void Enable() + { + if (buttonModule) + { + buttonModule.gameObject.SetActive(true); + if (WindowBar.useGUILayout) + { + LayoutRebuilder.ForceRebuildLayoutImmediate(WindowBar.BarPlane); + } + } + } + public virtual void Release() + { + if (button == null) + { + throw new InvalidOperationException("wrapper was released"); + } + if (buttonModule) + { + Disable(); + Destroy(buttonModule.gameObject); + if (WindowBar.useGUILayout) + { + LayoutRebuilder.ForceRebuildLayoutImmediate(WindowBar.BarPlane); + } + } + button = null; + } + ~RegisteredButtonWrapper() + { + Release(); + } + } + [return: ReturnNotNull, ReturnVirtual] + public virtual RegisteredButtonWrapper RegisterButton() + { + return new RegisteredButtonWrapper(this, InstantiateButton()); + } + [Serializable] + public class RegisteredPageWrapper : RegisteredButtonWrapper + { + [SerializeField]private int PageIndex = -1; + [SerializeField]private RectTransform plane, root; + public RegisteredPageWrapper(RectTransform plane, RectTransform root, [In] BaseWindowBar parentBar, [In] IButton button) : base(parentBar, button) + { + button.AddListener(() => WindowBar.m_WindowManager.SelectContextPlane(PageIndex)); + PageIndex = parentBar.m_WindowManager.AddContextPlane(plane, root); + this.plane = plane; + this.root = root; + } + public RegisteredPageWrapper(RectTransform plane, [In] BaseWindowBar parentBar, [In] IButton button) : base(parentBar, button) + { + button.AddListener(() => WindowBar.m_WindowManager.SelectContextPlane(PageIndex)); + PageIndex = parentBar.m_WindowManager.AddContextPlane(plane); + this.plane = plane; + } + public override void Disable() + { + if (PageIndex < 0) + { + return; + } + WindowBar.m_WindowManager.RemoveContextPlane(PageIndex); + PageIndex = -1; + base.Disable(); + } + public override void Enable() + { + if (PageIndex < 0) + { + WindowBar.m_WindowManager.AddContextPlane(plane, root); + base.Enable(); + } + } + public override void Release() + { + if (Application.isPlaying) + { + if (!plane) + throw new InvalidOperationException("page was released"); + else + return; + } + if (root) + { + root.gameObject.SetActive(false); + Destroy(root); + } + else + { + plane.gameObject.SetActive(false); + Destroy(plane); + } + base.Release(); + plane = null; + root = null; + } + public virtual void Select() + { + if (PageIndex < 0) + return; + WindowBar.m_WindowManager.SelectContextPlane(PageIndex); + } + } + [return: ReturnNotNull, ReturnVirtual] + public virtual RegisteredPageWrapper RegisterPage([In] RectTransform plane, [In] RectTransform root) + { + return new RegisteredPageWrapper(plane, root, this, InstantiateButton()); + } + [return: ReturnNotNull, ReturnVirtual] + public virtual RegisteredPageWrapper RegisterPage([In] RectTransform plane) + { + return new RegisteredPageWrapper(plane, this, InstantiateButton()); + } + + public virtual IEnumerable GetAllButton() + { + List result = new(); + foreach(IButton button in BarPlane.transform) + { + result.Add(button); + } + return result; + } + } +} diff --git a/Convention/[Visual]/UIComponent/BaseWindowBar.cs.meta b/Convention/[Visual]/UIComponent/BaseWindowBar.cs.meta new file mode 100644 index 0000000..2a8e569 --- /dev/null +++ b/Convention/[Visual]/UIComponent/BaseWindowBar.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f75b74b63b41ea54ba58bf470d6d74d8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/UIComponent/BaseWindowPlane.cs b/Convention/[Visual]/UIComponent/BaseWindowPlane.cs new file mode 100644 index 0000000..ff60b75 --- /dev/null +++ b/Convention/[Visual]/UIComponent/BaseWindowPlane.cs @@ -0,0 +1,124 @@ +using System; +using UnityEngine; +using UnityEngine.UI; + +namespace Convention.WindowsUI +{ + public class BaseWindowPlane : WindowsComponent + { + [Resources, SerializeField, OnlyNotNullMode] private RectTransform m_Plane; + [Resources, SerializeField, HopeNotNull, Tooltip("This animational plane should has the same parent transform")] + private RectTransform m_AnimationPlane; + [Setting, OnlyNotNullMode(nameof(m_AnimationPlane)), SerializeField, Header("Animation Setting")] + private bool IsEnableAnimation = true; + [Setting, OnlyNotNullMode(nameof(m_AnimationPlane)), Percentage(0, 1), Range(0, 1), WhenAttribute.Is(nameof(IsEnableAnimation), true)] + public float AnimationSpeed = 0.5f; + + public RectTransform Plane => m_Plane; + + [Content, OnlyPlayMode, Ignore] public RectTransformInfo BeforeMaximizeWindow = null; + [Content, OnlyPlayMode, Ignore] public float BeforeMaximizeWindowBackgroundColorA = 1f; + private bool IsMaximizeWindowMode = false; + [Content, OnlyPlayMode] + public void MaximizeWindow() + { + if (IsMaximizeWindowMode) + return; + BeforeMaximizeWindow = new(m_Plane); + var prect = m_Plane.transform.parent.GetComponent(); + m_Plane.SetPositionAndRotation(prect.position, prect.rotation); + m_Plane.anchoredPosition = Vector3.zero; + m_Plane.anchorMax = Vector2.one; + m_Plane.anchorMin = Vector2.zero; + m_Plane.sizeDelta = Vector2.zero; + var backgroundPlane = m_AnimationPlane == null ? m_Plane : m_AnimationPlane; + if (backgroundPlane.TryGetComponent(out var image)) + { + BeforeMaximizeWindowBackgroundColorA = image.color.a; + var color = image.color; + color.a = 1; + image.color = color; + } + IsMaximizeWindowMode = true; + } + [Content, OnlyPlayMode] + public void ExitMaximizeWindowMode() + { + if (!IsMaximizeWindowMode) + return; + BeforeMaximizeWindow.Setup(m_Plane); + var backgroundPlane = m_AnimationPlane == null ? m_Plane : m_AnimationPlane; + if (backgroundPlane.TryGetComponent(out var image)) + { + var color = image.color; + color.a = BeforeMaximizeWindowBackgroundColorA; + image.color = color; + } + IsMaximizeWindowMode = false; + } + + private void OnEnable() + { + if (m_AnimationPlane != null) + { + new RectTransformInfo(m_Plane).Setup(m_AnimationPlane); + } + } + [Content] + public void SynchronizedAnimationPlane() + { + new RectTransformInfo(m_Plane).Setup(m_AnimationPlane); + } + + private void LateUpdate() + { + if (IsEnableAnimation && m_Plane && m_AnimationPlane) + { + RectTransformInfo.UpdateAnimationPlane(m_Plane, m_AnimationPlane, AnimationSpeed, IsMaximizeWindowMode ? 1 : -1, false); + } + } + + public virtual void AddChild(RectTransform target, Rect rect, bool isAdjustSizeToContainsChilds = false) + { + RectTransformExtension.SetParentAndResizeWithoutNotifyBaseWindowPlane(m_Plane, target, rect, isAdjustSizeToContainsChilds); + } + public virtual void AddChild(RectTransform target, bool isAdjustSizeToContainsChilds = false) + { + RectTransformExtension.SetParentAndResizeWithoutNotifyBaseWindowPlane(m_Plane, target, isAdjustSizeToContainsChilds); + } + + [Content] + + public void ForceRebuildLayoutImmediate() + { + LayoutRebuilder.ForceRebuildLayoutImmediate(rectTransform); + } + + [Resources, Tooltip("before AdjustSizeToContainsChilds, will compute it first")] public RectTransform AdjustSizeToContainsRect; + + [Content] + public void AdjustSizeToContainsChilds() + { + if (AdjustSizeToContainsRect == null) + RectTransformExtension.AdjustSizeToContainsChilds(rectTransform); + else + { + var corners = new Vector3[4]; + Vector2 min = new Vector2(float.MaxValue, float.MaxValue); + Vector2 max = new Vector2(float.MinValue, float.MinValue); + AdjustSizeToContainsRect.GetWorldCorners(corners); + foreach (var corner in corners) + { + Vector2 localCorner = rectTransform.InverseTransformPoint(corner); + if (float.IsNaN(localCorner.x) || float.IsNaN(localCorner.y)) + break; + min.x = Mathf.Min(min.x, localCorner.x); + min.y = Mathf.Min(min.y, localCorner.y); + max.x = Mathf.Max(max.x, localCorner.x); + max.y = Mathf.Max(max.y, localCorner.y); + } + RectTransformExtension.AdjustSizeToContainsChilds(rectTransform, min, max, null); + } + } + } +} diff --git a/Convention/[Visual]/UIComponent/BaseWindowPlane.cs.meta b/Convention/[Visual]/UIComponent/BaseWindowPlane.cs.meta new file mode 100644 index 0000000..d482e60 --- /dev/null +++ b/Convention/[Visual]/UIComponent/BaseWindowPlane.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 999be728ad5e8324baf45ccaf0f9c3d2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/UIComponent/Canvas.controller b/Convention/[Visual]/UIComponent/Canvas.controller new file mode 100644 index 0000000..f3fba5e --- /dev/null +++ b/Convention/[Visual]/UIComponent/Canvas.controller @@ -0,0 +1,252 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1102 &-8092253087371084152 +AnimatorState: + serializedVersion: 6 + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: ExitFocusInspector + m_Speed: -1 + m_CycleOffset: 0 + m_Transitions: [] + m_StateMachineBehaviours: [] + m_Position: {x: 50, y: 50, z: 0} + m_IKOnFeet: 0 + m_WriteDefaultValues: 1 + m_Mirror: 0 + m_SpeedParameterActive: 0 + m_MirrorParameterActive: 0 + m_CycleOffsetParameterActive: 0 + m_TimeParameterActive: 0 + m_Motion: {fileID: 7400000, guid: 9525128e21aed17438d2688e99e7e20d, type: 2} + m_Tag: + m_SpeedParameter: + m_MirrorParameter: + m_CycleOffsetParameter: + m_TimeParameter: +--- !u!1102 &-6082174505553466741 +AnimatorState: + serializedVersion: 6 + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: ExitFullMainWindow + m_Speed: -1 + m_CycleOffset: 0 + m_Transitions: [] + m_StateMachineBehaviours: [] + m_Position: {x: 50, y: 50, z: 0} + m_IKOnFeet: 0 + m_WriteDefaultValues: 1 + m_Mirror: 0 + m_SpeedParameterActive: 0 + m_MirrorParameterActive: 0 + m_CycleOffsetParameterActive: 0 + m_TimeParameterActive: 0 + m_Motion: {fileID: 7400000, guid: 3c2a3f60d986c0149bf92b6d3983302e, type: 2} + m_Tag: + m_SpeedParameter: + m_MirrorParameter: + m_CycleOffsetParameter: + m_TimeParameter: +--- !u!1102 &-3932555576849271677 +AnimatorState: + serializedVersion: 6 + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: New State + m_Speed: 1 + m_CycleOffset: 0 + m_Transitions: [] + m_StateMachineBehaviours: [] + m_Position: {x: 50, y: 50, z: 0} + m_IKOnFeet: 0 + m_WriteDefaultValues: 1 + m_Mirror: 0 + m_SpeedParameterActive: 0 + m_MirrorParameterActive: 0 + m_CycleOffsetParameterActive: 0 + m_TimeParameterActive: 0 + m_Motion: {fileID: 0} + m_Tag: + m_SpeedParameter: + m_MirrorParameter: + m_CycleOffsetParameter: + m_TimeParameter: +--- !u!1102 &-2403780335683535720 +AnimatorState: + serializedVersion: 6 + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: FullMainWindow + m_Speed: 1 + m_CycleOffset: 0 + m_Transitions: [] + m_StateMachineBehaviours: [] + m_Position: {x: 50, y: 50, z: 0} + m_IKOnFeet: 0 + m_WriteDefaultValues: 1 + m_Mirror: 0 + m_SpeedParameterActive: 0 + m_MirrorParameterActive: 0 + m_CycleOffsetParameterActive: 0 + m_TimeParameterActive: 0 + m_Motion: {fileID: 7400000, guid: 3c2a3f60d986c0149bf92b6d3983302e, type: 2} + m_Tag: + m_SpeedParameter: + m_MirrorParameter: + m_CycleOffsetParameter: + m_TimeParameter: +--- !u!91 &9100000 +AnimatorController: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Canvas + serializedVersion: 5 + m_AnimatorParameters: + - m_Name: IsFocus + m_Type: 4 + m_DefaultFloat: 0 + m_DefaultInt: 0 + m_DefaultBool: 0 + m_Controller: {fileID: 9100000} + m_AnimatorLayers: + - serializedVersion: 5 + m_Name: Base Layer + m_StateMachine: {fileID: 1296624602851365648} + m_Mask: {fileID: 0} + m_Motions: [] + m_Behaviours: [] + m_BlendingMode: 0 + m_SyncedLayerIndex: -1 + m_DefaultWeight: 0 + m_IKPass: 0 + m_SyncedLayerAffectsTiming: 0 + m_Controller: {fileID: 9100000} +--- !u!1107 &1296624602851365648 +AnimatorStateMachine: + serializedVersion: 6 + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Base Layer + m_ChildStates: + - serializedVersion: 1 + m_State: {fileID: 6070089197181197078} + m_Position: {x: 450, y: -10, z: 0} + - serializedVersion: 1 + m_State: {fileID: -3932555576849271677} + m_Position: {x: 10, y: 70, z: 0} + - serializedVersion: 1 + m_State: {fileID: 1675010782392993655} + m_Position: {x: 450, y: 50, z: 0} + - serializedVersion: 1 + m_State: {fileID: -2403780335683535720} + m_Position: {x: 670, y: -10, z: 0} + - serializedVersion: 1 + m_State: {fileID: -6082174505553466741} + m_Position: {x: 670, y: 50, z: 0} + - serializedVersion: 1 + m_State: {fileID: 1810835025064308519} + m_Position: {x: 450, y: 110, z: 0} + - serializedVersion: 1 + m_State: {fileID: -8092253087371084152} + m_Position: {x: 450, y: 160, z: 0} + m_ChildStateMachines: [] + m_AnyStateTransitions: [] + m_EntryTransitions: [] + m_StateMachineTransitions: {} + m_StateMachineBehaviours: [] + m_AnyStatePosition: {x: 50, y: 20, z: 0} + m_EntryPosition: {x: 50, y: 120, z: 0} + m_ExitPosition: {x: 50, y: -20, z: 0} + m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} + m_DefaultState: {fileID: -3932555576849271677} +--- !u!1102 &1675010782392993655 +AnimatorState: + serializedVersion: 6 + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: ExitFocusMainWindow + m_Speed: -1 + m_CycleOffset: 0 + m_Transitions: [] + m_StateMachineBehaviours: [] + m_Position: {x: 50, y: 50, z: 0} + m_IKOnFeet: 0 + m_WriteDefaultValues: 1 + m_Mirror: 0 + m_SpeedParameterActive: 0 + m_MirrorParameterActive: 0 + m_CycleOffsetParameterActive: 0 + m_TimeParameterActive: 0 + m_Motion: {fileID: 7400000, guid: ca95e26c36202a54fb6f43ca904d2bcf, type: 2} + m_Tag: + m_SpeedParameter: + m_MirrorParameter: + m_CycleOffsetParameter: + m_TimeParameter: +--- !u!1102 &1810835025064308519 +AnimatorState: + serializedVersion: 6 + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: FocusInspector + m_Speed: 1 + m_CycleOffset: 0 + m_Transitions: [] + m_StateMachineBehaviours: [] + m_Position: {x: 50, y: 50, z: 0} + m_IKOnFeet: 0 + m_WriteDefaultValues: 1 + m_Mirror: 0 + m_SpeedParameterActive: 0 + m_MirrorParameterActive: 0 + m_CycleOffsetParameterActive: 0 + m_TimeParameterActive: 0 + m_Motion: {fileID: 7400000, guid: 9525128e21aed17438d2688e99e7e20d, type: 2} + m_Tag: + m_SpeedParameter: + m_MirrorParameter: + m_CycleOffsetParameter: + m_TimeParameter: +--- !u!1102 &6070089197181197078 +AnimatorState: + serializedVersion: 6 + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: FocusMainWindow + m_Speed: 1 + m_CycleOffset: 0 + m_Transitions: [] + m_StateMachineBehaviours: [] + m_Position: {x: 50, y: 50, z: 0} + m_IKOnFeet: 0 + m_WriteDefaultValues: 1 + m_Mirror: 0 + m_SpeedParameterActive: 0 + m_MirrorParameterActive: 0 + m_CycleOffsetParameterActive: 0 + m_TimeParameterActive: 0 + m_Motion: {fileID: 7400000, guid: ca95e26c36202a54fb6f43ca904d2bcf, type: 2} + m_Tag: + m_SpeedParameter: + m_MirrorParameter: + m_CycleOffsetParameter: + m_TimeParameter: diff --git a/Convention/[Visual]/UIComponent/Canvas.controller.meta b/Convention/[Visual]/UIComponent/Canvas.controller.meta new file mode 100644 index 0000000..54abb74 --- /dev/null +++ b/Convention/[Visual]/UIComponent/Canvas.controller.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e407ea59aaf27714e830a008e8f5f2f3 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/UIComponent/ClickBoard.cs b/Convention/[Visual]/UIComponent/ClickBoard.cs new file mode 100644 index 0000000..32b155b --- /dev/null +++ b/Convention/[Visual]/UIComponent/ClickBoard.cs @@ -0,0 +1,36 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.EventSystems; +using UnityEngine.InputSystem; +using UnityEngine.InputSystem.Controls; + +namespace Convention.WindowsUI +{ + public class ClickBoard : WindowUIModule + { + [Resources] public BehaviourContextManager Context; + + [Setting] public UnityEvent LeftButtonClick = new(); + [Setting] public UnityEvent RightButtonClick = new(); + + private void Start() + { + if (Context == null) + Context = this.GetOrAddComponent(); + + Context.OnPointerClickEvent = BehaviourContextManager.InitializeContextSingleEvent(Context.OnPointerClickEvent, point => + { + if (point.button == PointerEventData.InputButton.Left) + { + LeftButtonClick.Invoke(point); + } + if (point.button == PointerEventData.InputButton.Right) + { + RightButtonClick.Invoke(point); + } + }); + } + } +} diff --git a/Convention/[Visual]/UIComponent/ClickBoard.cs.meta b/Convention/[Visual]/UIComponent/ClickBoard.cs.meta new file mode 100644 index 0000000..6b845bd --- /dev/null +++ b/Convention/[Visual]/UIComponent/ClickBoard.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 23af7c7b9a98a1b4a9614459934e2aec +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Visual]/UIComponent/CustomMenu.cs b/Convention/[Visual]/UIComponent/CustomMenu.cs new file mode 100644 index 0000000..f94d6cd --- /dev/null +++ b/Convention/[Visual]/UIComponent/CustomMenu.cs @@ -0,0 +1,49 @@ +using System.Collections.Generic; +using Convention.WindowsUI; +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.UI; + +namespace Convention +{ + public class CustomMenu : WindowsComponent + { + [Setting, SerializeField] private bool IsDestroy = true; + [Resources, SerializeField, OnlyNotNullMode] private Button ButtonPrefab; + [Resources, SerializeField, OnlyNotNullMode] private RectTransform Plane; + [Content] public List childs = new(); + + [Content, OnlyPlayMode] + [return: IsInstantiated(true)] + public virtual Button CreateItem() + { + var item = GameObject.Instantiate(ButtonPrefab, Plane).GetComponent