From 162048429753d14ba164f5d0e5d019883d57b2fe Mon Sep 17 00:00:00 2001 From: DCFApixels <99481254+DCFApixels@users.noreply.github.com> Date: Mon, 24 Mar 2025 13:51:44 +0800 Subject: [PATCH] rework UnityDebugService initialization --- .../UnityDebugService/UnityDebugService.cs | 17 +---------------- src/Internal/Editor/UnityEditorUtility.cs | 8 +++++--- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/DebugUtils/UnityDebugService/UnityDebugService.cs b/src/DebugUtils/UnityDebugService/UnityDebugService.cs index c5ad121..3aed828 100644 --- a/src/DebugUtils/UnityDebugService/UnityDebugService.cs +++ b/src/DebugUtils/UnityDebugService/UnityDebugService.cs @@ -1,30 +1,15 @@ using DCFApixels.DragonECS.Unity.Internal; using System; -using System.Reflection; using Unity.Profiling; -using UnityEditor; using UnityEngine; -#region [InitializeOnLoad] -#if UNITY_EDITOR -namespace DCFApixels.DragonECS -{ - using UnityEditor; - [InitializeOnLoad] - public partial class UnityDebugService { } -} -#endif -#endregion namespace DCFApixels.DragonECS { // Методы юнитевского Debug и ProfilerMarker потоко безопасны public partial class UnityDebugService : DebugService { private ProfilerMarker[] _profilerMarkers = new ProfilerMarker[64]; - static UnityDebugService() - { - Activate(); - } + public static void Activate() { if (Instance.GetType() == typeof(UnityDebugService)) { return; } diff --git a/src/Internal/Editor/UnityEditorUtility.cs b/src/Internal/Editor/UnityEditorUtility.cs index 09d0e0f..3abe0ff 100644 --- a/src/Internal/Editor/UnityEditorUtility.cs +++ b/src/Internal/Editor/UnityEditorUtility.cs @@ -109,8 +109,7 @@ namespace DCFApixels.DragonECS.Unity.Editors static UnityEditorUtility() { const int PREWARMUP_LIST_SIZE = 64; - EcsWorld.ResetStaticState(); - UnityDebugService.Activate(); + OnLoad(); _integrationAssembly = typeof(UnityEditorUtility).Assembly; @@ -212,7 +211,10 @@ namespace DCFApixels.DragonECS.Unity.Editors private static void OnLoad() { EcsWorld.ResetStaticState(); - UnityDebugService.Activate(); + if (DebugService.IsNullOrDefault) + { + UnityDebugService.Activate(); + } } internal static readonly Assembly _integrationAssembly;