From c8d5bb20c35faf6112adccb5865888ce9f5a584f Mon Sep 17 00:00:00 2001 From: ls9512 <598914653@qq.com> Date: Thu, 27 Jul 2023 11:17:07 +0800 Subject: [PATCH] Add UEvent Project Setting --- CSharp/Script/UEvent.cs | 9 ++++++++ Unity/Editor/Script/Monitor.meta | 8 +++++++ .../Script/{ => Monitor}/EventLogData.cs | 2 +- .../Script/{ => Monitor}/EventLogData.cs.meta | 0 .../Script/{ => Monitor}/EventMonitor.cs | 10 ++++---- .../Script/{ => Monitor}/EventMonitor.cs.meta | 0 .../EventMonitorStyleSetting.cs | 0 .../EventMonitorStyleSetting.cs.meta | 0 Unity/Editor/Script/{ => Monitor}/GUI.meta | 0 .../Script/{ => Monitor}/GUI/GUIHelper.cs | 2 +- .../{ => Monitor}/GUI/GUIHelper.cs.meta | 0 .../Script/{ => Monitor}/GUI/GUITable.cs | 0 .../Script/{ => Monitor}/GUI/GUITable.cs.meta | 0 ...ditorSetting.cs => UEventEditorSetting.cs} | 12 +++++----- ...ng.cs.meta => UEventEditorSetting.cs.meta} | 0 Unity/Editor/Script/UEventEditorMenu.cs | 21 +++++++++++++++++ Unity/Editor/Script/UEventEditorMenu.cs.meta | 11 +++++++++ .../Script/UEventEditorSettingProvider.cs | 23 +++++++++++++++++++ .../UEventEditorSettingProvider.cs.meta | 11 +++++++++ Unity/Runtime/Script/Handler/EventHandler.cs | 16 ++++++------- 20 files changed, 103 insertions(+), 22 deletions(-) create mode 100644 Unity/Editor/Script/Monitor.meta rename Unity/Editor/Script/{ => Monitor}/EventLogData.cs (93%) rename Unity/Editor/Script/{ => Monitor}/EventLogData.cs.meta (100%) rename Unity/Editor/Script/{ => Monitor}/EventMonitor.cs (95%) rename Unity/Editor/Script/{ => Monitor}/EventMonitor.cs.meta (100%) rename Unity/Editor/Script/{Setting => Monitor}/EventMonitorStyleSetting.cs (100%) rename Unity/Editor/Script/{Setting => Monitor}/EventMonitorStyleSetting.cs.meta (100%) rename Unity/Editor/Script/{ => Monitor}/GUI.meta (100%) rename Unity/Editor/Script/{ => Monitor}/GUI/GUIHelper.cs (99%) rename Unity/Editor/Script/{ => Monitor}/GUI/GUIHelper.cs.meta (100%) rename Unity/Editor/Script/{ => Monitor}/GUI/GUITable.cs (100%) rename Unity/Editor/Script/{ => Monitor}/GUI/GUITable.cs.meta (100%) rename Unity/Editor/Script/Setting/{EventEditorSetting.cs => UEventEditorSetting.cs} (80%) rename Unity/Editor/Script/Setting/{EventEditorSetting.cs.meta => UEventEditorSetting.cs.meta} (100%) create mode 100644 Unity/Editor/Script/UEventEditorMenu.cs create mode 100644 Unity/Editor/Script/UEventEditorMenu.cs.meta create mode 100644 Unity/Editor/Script/UEventEditorSettingProvider.cs create mode 100644 Unity/Editor/Script/UEventEditorSettingProvider.cs.meta diff --git a/CSharp/Script/UEvent.cs b/CSharp/Script/UEvent.cs index d307eb0..bb24072 100644 --- a/CSharp/Script/UEvent.cs +++ b/CSharp/Script/UEvent.cs @@ -14,6 +14,15 @@ namespace Aya.Events { public static partial class UEvent { + #region Register + + public static void Register(Type objType) + { + EventListener.Register(objType); + } + + #endregion + #region Listen Action public static void Listen(Action action, object group = null, int priority = 0, bool interrupt = false) diff --git a/Unity/Editor/Script/Monitor.meta b/Unity/Editor/Script/Monitor.meta new file mode 100644 index 0000000..c80dd75 --- /dev/null +++ b/Unity/Editor/Script/Monitor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 094ba7f1f14d0494ca385845dc33d765 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Editor/Script/EventLogData.cs b/Unity/Editor/Script/Monitor/EventLogData.cs similarity index 93% rename from Unity/Editor/Script/EventLogData.cs rename to Unity/Editor/Script/Monitor/EventLogData.cs index 8c41a88..d7fecf5 100644 --- a/Unity/Editor/Script/EventLogData.cs +++ b/Unity/Editor/Script/Monitor/EventLogData.cs @@ -28,7 +28,7 @@ public string Log if (string.IsNullOrEmpty(_log)) { var stringBuilder = new StringBuilder(); - stringBuilder.Append(DateTime.ToString(EventEditorSetting.Ins.DateFormat)); + stringBuilder.Append(DateTime.ToString(UEventEditorSetting.Ins.DateFormat)); stringBuilder.Append("\t"); stringBuilder.Append(EventType); stringBuilder.Append("\t"); diff --git a/Unity/Editor/Script/EventLogData.cs.meta b/Unity/Editor/Script/Monitor/EventLogData.cs.meta similarity index 100% rename from Unity/Editor/Script/EventLogData.cs.meta rename to Unity/Editor/Script/Monitor/EventLogData.cs.meta diff --git a/Unity/Editor/Script/EventMonitor.cs b/Unity/Editor/Script/Monitor/EventMonitor.cs similarity index 95% rename from Unity/Editor/Script/EventMonitor.cs rename to Unity/Editor/Script/Monitor/EventMonitor.cs index bc4c5ad..80d14bb 100644 --- a/Unity/Editor/Script/EventMonitor.cs +++ b/Unity/Editor/Script/Monitor/EventMonitor.cs @@ -9,7 +9,6 @@ #if UNITY_EDITOR using System; using System.Collections.Generic; -using System.Reflection; using UnityEditor; using UnityEngine; @@ -21,7 +20,6 @@ public class EventMonitor : EditorWindow public static EventMonitor Instance; - [MenuItem("Tools/Aya Game/UEvent/Event Monitor", false, 0)] public static void ShowWindow() { if (Instance == null) @@ -182,17 +180,17 @@ private Color GetRowColor(EventHandler eventHandler) var rowColor = GUI.backgroundColor; if (eventHandler.IsInvokeSuccess) { - rowColor = Color.Lerp(EventEditorSetting.Ins.MonitorStyle.TipSuccessColor, GUI.backgroundColor, eventHandler.InvokeSuccessProgress); + rowColor = Color.Lerp(UEventEditorSetting.Ins.MonitorStyle.TipSuccessColor, GUI.backgroundColor, eventHandler.InvokeSuccessProgress); } if (eventHandler.IsInvokeFail) { - rowColor = Color.Lerp(EventEditorSetting.Ins.MonitorStyle.TipFailColor, GUI.backgroundColor, eventHandler.InvokeFailProgress); + rowColor = Color.Lerp(UEventEditorSetting.Ins.MonitorStyle.TipFailColor, GUI.backgroundColor, eventHandler.InvokeFailProgress); } if (eventHandler.IsListening) { - rowColor = Color.Lerp(EventEditorSetting.Ins.MonitorStyle.TipListenColor, GUI.backgroundColor, eventHandler.ListeningProgress); + rowColor = Color.Lerp(UEventEditorSetting.Ins.MonitorStyle.TipListenColor, GUI.backgroundColor, eventHandler.ListeningProgress); } return rowColor; @@ -349,7 +347,7 @@ public void DrawCellLastTime(int index, float width, EventHandler eventHandler) { if (eventHandler.DispatchCounter > 0) { - GUILayout.Label(eventHandler.LastInvokeDateTime.ToString(EventEditorSetting.Ins.MonitorStyle.DateFormat)); + GUILayout.Label(eventHandler.LastInvokeDateTime.ToString(UEventEditorSetting.Ins.MonitorStyle.DateFormat)); } else { diff --git a/Unity/Editor/Script/EventMonitor.cs.meta b/Unity/Editor/Script/Monitor/EventMonitor.cs.meta similarity index 100% rename from Unity/Editor/Script/EventMonitor.cs.meta rename to Unity/Editor/Script/Monitor/EventMonitor.cs.meta diff --git a/Unity/Editor/Script/Setting/EventMonitorStyleSetting.cs b/Unity/Editor/Script/Monitor/EventMonitorStyleSetting.cs similarity index 100% rename from Unity/Editor/Script/Setting/EventMonitorStyleSetting.cs rename to Unity/Editor/Script/Monitor/EventMonitorStyleSetting.cs diff --git a/Unity/Editor/Script/Setting/EventMonitorStyleSetting.cs.meta b/Unity/Editor/Script/Monitor/EventMonitorStyleSetting.cs.meta similarity index 100% rename from Unity/Editor/Script/Setting/EventMonitorStyleSetting.cs.meta rename to Unity/Editor/Script/Monitor/EventMonitorStyleSetting.cs.meta diff --git a/Unity/Editor/Script/GUI.meta b/Unity/Editor/Script/Monitor/GUI.meta similarity index 100% rename from Unity/Editor/Script/GUI.meta rename to Unity/Editor/Script/Monitor/GUI.meta diff --git a/Unity/Editor/Script/GUI/GUIHelper.cs b/Unity/Editor/Script/Monitor/GUI/GUIHelper.cs similarity index 99% rename from Unity/Editor/Script/GUI/GUIHelper.cs rename to Unity/Editor/Script/Monitor/GUI/GUIHelper.cs index 0275332..0c6cef7 100644 --- a/Unity/Editor/Script/GUI/GUIHelper.cs +++ b/Unity/Editor/Script/Monitor/GUI/GUIHelper.cs @@ -54,7 +54,7 @@ public static GUIStyle LinkActiveStyle }, normal = new GUIStyleState() { - textColor = EventEditorSetting.Ins.MonitorStyle.ActiveUrlColor + textColor = UEventEditorSetting.Ins.MonitorStyle.ActiveUrlColor }, alignment = TextAnchor.MiddleLeft, richText = false diff --git a/Unity/Editor/Script/GUI/GUIHelper.cs.meta b/Unity/Editor/Script/Monitor/GUI/GUIHelper.cs.meta similarity index 100% rename from Unity/Editor/Script/GUI/GUIHelper.cs.meta rename to Unity/Editor/Script/Monitor/GUI/GUIHelper.cs.meta diff --git a/Unity/Editor/Script/GUI/GUITable.cs b/Unity/Editor/Script/Monitor/GUI/GUITable.cs similarity index 100% rename from Unity/Editor/Script/GUI/GUITable.cs rename to Unity/Editor/Script/Monitor/GUI/GUITable.cs diff --git a/Unity/Editor/Script/GUI/GUITable.cs.meta b/Unity/Editor/Script/Monitor/GUI/GUITable.cs.meta similarity index 100% rename from Unity/Editor/Script/GUI/GUITable.cs.meta rename to Unity/Editor/Script/Monitor/GUI/GUITable.cs.meta diff --git a/Unity/Editor/Script/Setting/EventEditorSetting.cs b/Unity/Editor/Script/Setting/UEventEditorSetting.cs similarity index 80% rename from Unity/Editor/Script/Setting/EventEditorSetting.cs rename to Unity/Editor/Script/Setting/UEventEditorSetting.cs index e972e95..4a923e7 100644 --- a/Unity/Editor/Script/Setting/EventEditorSetting.cs +++ b/Unity/Editor/Script/Setting/UEventEditorSetting.cs @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// Script : EventEditorSetting.cs +// Script : UEventEditorSetting.cs // Info : 事件编辑器配置类 // Author : ls9512 2021 // E-mail : ls9512@vip.qq.com @@ -12,25 +12,25 @@ namespace Aya.Events { - [CreateAssetMenu(menuName = "UEvent/Event Editor Setting", fileName = "EventEditorSetting")] - public class EventEditorSetting : ScriptableObject + [CreateAssetMenu(menuName = "UEvent/Event Editor Setting", fileName = "UEventEditorSetting")] + public class UEventEditorSetting : ScriptableObject { #region Instance - public static EventEditorSetting Ins + public static UEventEditorSetting Ins { get { if (Instance == null) { - Instance = FindAsset(); + Instance = FindAsset(); } return Instance; } } - protected static EventEditorSetting Instance; + protected static UEventEditorSetting Instance; internal static T FindAsset() where T : Object { diff --git a/Unity/Editor/Script/Setting/EventEditorSetting.cs.meta b/Unity/Editor/Script/Setting/UEventEditorSetting.cs.meta similarity index 100% rename from Unity/Editor/Script/Setting/EventEditorSetting.cs.meta rename to Unity/Editor/Script/Setting/UEventEditorSetting.cs.meta diff --git a/Unity/Editor/Script/UEventEditorMenu.cs b/Unity/Editor/Script/UEventEditorMenu.cs new file mode 100644 index 0000000..4f231f7 --- /dev/null +++ b/Unity/Editor/Script/UEventEditorMenu.cs @@ -0,0 +1,21 @@ +#if UNITY_EDITOR +using UnityEditor; + +namespace Aya.Events +{ + public partial class UEventEditorMenu + { + [MenuItem("Tools/Aya Game/UEvent/Event Monitor", false, 0)] + public static void OpenEventMonitor() + { + EventMonitor.ShowWindow(); + } + + [MenuItem("Tools/Aya Game/UEvent/Editor Setting", false, 1000)] + public static void OpenRuntimeSetting() + { + SettingsService.OpenProjectSettings("Aya Game/UEvent Editor"); + } + } +} +#endif \ No newline at end of file diff --git a/Unity/Editor/Script/UEventEditorMenu.cs.meta b/Unity/Editor/Script/UEventEditorMenu.cs.meta new file mode 100644 index 0000000..5685652 --- /dev/null +++ b/Unity/Editor/Script/UEventEditorMenu.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9f72e40977235b949827734ac71bd291 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Editor/Script/UEventEditorSettingProvider.cs b/Unity/Editor/Script/UEventEditorSettingProvider.cs new file mode 100644 index 0000000..addb49e --- /dev/null +++ b/Unity/Editor/Script/UEventEditorSettingProvider.cs @@ -0,0 +1,23 @@ +#if UNITY_EDITOR +using Aya.Events; +using UnityEditor; + +namespace Aya.TweenPro +{ + public static class UEventEditorSettingProvider + { + #region Project Setting + + [SettingsProvider] + public static SettingsProvider GetEditorSetting() + { + var provider = AssetSettingsProvider.CreateProviderFromObject("Aya Game/UEvent Editor", UEventEditorSetting.Ins); + provider.keywords = SettingsProvider.GetSearchKeywordsFromSerializedObject(new SerializedObject(UEventEditorSetting.Ins)); + return provider; + } + + #endregion + } +} + +#endif \ No newline at end of file diff --git a/Unity/Editor/Script/UEventEditorSettingProvider.cs.meta b/Unity/Editor/Script/UEventEditorSettingProvider.cs.meta new file mode 100644 index 0000000..46f338c --- /dev/null +++ b/Unity/Editor/Script/UEventEditorSettingProvider.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bc5b68080cda6d247bdd07d109890dcd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Runtime/Script/Handler/EventHandler.cs b/Unity/Runtime/Script/Handler/EventHandler.cs index 25ae912..446db08 100644 --- a/Unity/Runtime/Script/Handler/EventHandler.cs +++ b/Unity/Runtime/Script/Handler/EventHandler.cs @@ -101,7 +101,7 @@ internal static void CacheLog(EventHandler eventHandler, object eventType, objec log.Parameters += "]"; Logs.Add(log); - if (Logs.Count > EventEditorSetting.Ins.CacheLogCount) + if (Logs.Count > UEventEditorSetting.Ins.CacheLogCount) { Logs.RemoveAt(0); } @@ -166,7 +166,7 @@ private string GetSignature(MethodInfo methodInfo, bool richText) var stringBuilder = new StringBuilder(); - if (richText) stringBuilder.Append(GetColorMarkupStart(EventEditorSetting.Ins.MonitorStyle.CodeKeyWordColor)); + if (richText) stringBuilder.Append(GetColorMarkupStart(UEventEditorSetting.Ins.MonitorStyle.CodeKeyWordColor)); if (methodInfo.IsPrivate) { stringBuilder.Append("private "); @@ -204,26 +204,26 @@ private string GetSignature(MethodInfo methodInfo, bool richText) if (richText) stringBuilder.Append(GetColorMarkupEnd()); - if (richText) stringBuilder.Append(GetColorMarkupStart(EventEditorSetting.Ins.MonitorStyle.CodeParameterColor)); + if (richText) stringBuilder.Append(GetColorMarkupStart(UEventEditorSetting.Ins.MonitorStyle.CodeParameterColor)); stringBuilder.Append(methodInfo.ReturnType.Name); if (richText) stringBuilder.Append(GetColorMarkupEnd()); stringBuilder.Append(" "); - if (richText) stringBuilder.Append(GetColorMarkupStart(EventEditorSetting.Ins.MonitorStyle.CodeMethodColor)); + if (richText) stringBuilder.Append(GetColorMarkupStart(UEventEditorSetting.Ins.MonitorStyle.CodeMethodColor)); stringBuilder.Append(methodInfo.Name); if (richText) stringBuilder.Append(GetColorMarkupEnd()); - if (richText) stringBuilder.Append(GetColorMarkupStart(EventEditorSetting.Ins.MonitorStyle.CodeNormalColor)); + if (richText) stringBuilder.Append(GetColorMarkupStart(UEventEditorSetting.Ins.MonitorStyle.CodeNormalColor)); stringBuilder.Append("("); if (richText) stringBuilder.Append(GetColorMarkupEnd()); var parameters = methodInfo.GetParameters(); for (var i = 0; i < parameters.Length; i++) { var parameter = parameters[i]; - if (richText) stringBuilder.Append(GetColorMarkupStart(EventEditorSetting.Ins.MonitorStyle.CodeParameterColor)); + if (richText) stringBuilder.Append(GetColorMarkupStart(UEventEditorSetting.Ins.MonitorStyle.CodeParameterColor)); stringBuilder.Append(parameter.ParameterType.Name); if (richText) stringBuilder.Append(GetColorMarkupEnd()); stringBuilder.Append(" "); - if (richText) stringBuilder.Append(GetColorMarkupStart(EventEditorSetting.Ins.MonitorStyle.CodeNormalColor)); + if (richText) stringBuilder.Append(GetColorMarkupStart(UEventEditorSetting.Ins.MonitorStyle.CodeNormalColor)); stringBuilder.Append(parameter.Name); if (i < parameters.Length - 1) { @@ -233,7 +233,7 @@ private string GetSignature(MethodInfo methodInfo, bool richText) if (richText) stringBuilder.Append(GetColorMarkupEnd()); } - if (richText) stringBuilder.Append(GetColorMarkupStart(EventEditorSetting.Ins.MonitorStyle.CodeNormalColor)); + if (richText) stringBuilder.Append(GetColorMarkupStart(UEventEditorSetting.Ins.MonitorStyle.CodeNormalColor)); stringBuilder.Append(")"); if (richText) stringBuilder.Append(GetColorMarkupEnd()); return stringBuilder.ToString();