add EcsDebug.OnPrint event

This commit is contained in:
DCFApixels 2024-12-18 16:17:57 +08:00
parent 0905aa476c
commit fb23398853

View File

@ -92,6 +92,7 @@ namespace DCFApixels.DragonECS
public static void PrintWarning(object v) public static void PrintWarning(object v)
{ {
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER #if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER
OnPrint(DEBUG_WARNING_TAG, v);
DebugService.CurrentThreadInstance.PrintWarning(v); DebugService.CurrentThreadInstance.PrintWarning(v);
#endif #endif
} }
@ -99,6 +100,7 @@ namespace DCFApixels.DragonECS
public static void PrintError(object v) public static void PrintError(object v)
{ {
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER #if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER
OnPrint(DEBUG_ERROR_TAG, v);
DebugService.CurrentThreadInstance.PrintError(v); DebugService.CurrentThreadInstance.PrintError(v);
#endif #endif
} }
@ -106,6 +108,7 @@ namespace DCFApixels.DragonECS
public static void PrintErrorAndBreak(object v) public static void PrintErrorAndBreak(object v)
{ {
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER #if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER
OnPrint(DEBUG_ERROR_TAG, v);
DebugService.CurrentThreadInstance.PrintErrorAndBreak(v); DebugService.CurrentThreadInstance.PrintErrorAndBreak(v);
#endif #endif
} }
@ -113,6 +116,7 @@ namespace DCFApixels.DragonECS
public static void PrintPass(object v) public static void PrintPass(object v)
{ {
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER #if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER
OnPrint(DEBUG_PASS_TAG, v);
DebugService.CurrentThreadInstance.PrintPass(v); DebugService.CurrentThreadInstance.PrintPass(v);
#endif #endif
} }
@ -120,6 +124,7 @@ namespace DCFApixels.DragonECS
public static void Print() public static void Print()
{ {
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER #if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER
OnPrint(string.Empty, null);
DebugService.CurrentThreadInstance.Print(); DebugService.CurrentThreadInstance.Print();
#endif #endif
} }
@ -127,6 +132,7 @@ namespace DCFApixels.DragonECS
public static void Print(object v) public static void Print(object v)
{ {
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER #if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER
OnPrint(string.Empty, v);
DebugService.CurrentThreadInstance.Print(v); DebugService.CurrentThreadInstance.Print(v);
#endif #endif
} }
@ -134,6 +140,7 @@ namespace DCFApixels.DragonECS
public static void Print(string tag, object v) public static void Print(string tag, object v)
{ {
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER #if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER
OnPrint(tag, v);
DebugService.CurrentThreadInstance.Print(tag, v); DebugService.CurrentThreadInstance.Print(tag, v);
#endif #endif
} }
@ -144,6 +151,9 @@ namespace DCFApixels.DragonECS
DebugService.CurrentThreadInstance.Break(); DebugService.CurrentThreadInstance.Break();
#endif #endif
} }
public static OnPrintHandler OnPrint = delegate { };
public delegate void OnPrintHandler(string tag, object v);
} }
//------------------------------------------------------------------------------------------------------------// //------------------------------------------------------------------------------------------------------------//
@ -315,7 +325,9 @@ namespace DCFApixels.DragonECS
} }
#endregion #endregion
public static Action<DebugService> OnServiceChanged = delegate { }; public static OnServiceChangedHandler OnServiceChanged = delegate { };
public delegate void OnServiceChangedHandler(DebugService service);
} }
public static class DebugServiceExtensions public static class DebugServiceExtensions
{ {