diff --git a/src/DebugUtils/EcsDebug.cs b/src/DebugUtils/EcsDebug.cs index 6742a91..0356dcc 100644 --- a/src/DebugUtils/EcsDebug.cs +++ b/src/DebugUtils/EcsDebug.cs @@ -143,6 +143,7 @@ namespace DCFApixels.DragonECS Name = name; ID = iD; } + public override string ToString() { return this.AutoToString(); } } public IEnumerable MarkerInfos { @@ -167,14 +168,15 @@ namespace DCFApixels.DragonECS { var oldService = _instance; _instance = service; - - foreach (var info in oldService.MarkerInfos) - { - service._idDispenser.Use(info.ID); - service._nameIdTable.TryAdd(info.Name, info.ID); - service.OnNewProfilerMark(info.ID, info.Name); + if(_instance != null) + { //TODO Так, всеже треды влияют друг на друга, скоерее всего проблема в использовании _nameIdTable + foreach (var info in oldService.MarkerInfos) + { + service._idDispenser.Use(info.ID); + service._nameIdTable.TryAdd(info.Name, info.ID); + service.OnNewProfilerMark(info.ID, info.Name); + } } - service.OnServiceSetup(oldService); OnServiceChanged(service); } @@ -263,6 +265,10 @@ namespace DCFApixels.DragonECS Name = name; ID = id; } + public override string ToString() + { + return this.AutoToString(); + } } private MarkerData[] _stopwatchs; [ThreadStatic] @@ -318,10 +324,10 @@ namespace DCFApixels.DragonECS var color = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.DarkGray; - _stopwatchs[id].stopwatch.Start(); + _stopwatchs[id].Stopwatch.Start(); Console.Write(PROFILER_MARKER_CACHE); - Console.Write(_stopwatchs[id].name); + Console.Write(_stopwatchs[id].Name); Console.WriteLine("> "); Console.ForegroundColor = color; @@ -332,13 +338,13 @@ namespace DCFApixels.DragonECS #if ((DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER) && !UNITY_5_3_OR_NEWER var color = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.DarkGray; - _stopwatchs[id].stopwatch.Stop(); - var time = _stopwatchs[id].stopwatch.Elapsed; - _stopwatchs[id].stopwatch.Reset(); + _stopwatchs[id].Stopwatch.Stop(); + var time = _stopwatchs[id].Stopwatch.Elapsed; + _stopwatchs[id].Stopwatch.Reset(); Console.Write(PROFILER_MARKER_CACHE); Console.Write("> "); - Console.Write(_stopwatchs[id].name); + Console.Write(_stopwatchs[id].Name); Console.Write(" s:"); int written = 0;