mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-19 02:24:35 +08:00
fix debug service
This commit is contained in:
parent
762ba241da
commit
0862067ddd
@ -6,14 +6,22 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
public class UnityDebugService : DebugService
|
public class UnityDebugService : DebugService
|
||||||
{
|
{
|
||||||
public static void Init() => Set<UnityDebugService>();
|
|
||||||
|
|
||||||
private ProfilerMarker[] _profilerMarkers = new ProfilerMarker[64];
|
private ProfilerMarker[] _profilerMarkers = new ProfilerMarker[64];
|
||||||
|
|
||||||
|
public static void Activate()
|
||||||
|
{
|
||||||
|
Set<UnityDebugService>();
|
||||||
|
}
|
||||||
public override void Print(string tag, object v)
|
public override void Print(string tag, object v)
|
||||||
{
|
{
|
||||||
string log;
|
string log;
|
||||||
if (!string.IsNullOrEmpty(tag))
|
if (v is Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasTag = string.IsNullOrEmpty(tag) == false;
|
||||||
|
if (hasTag)
|
||||||
{
|
{
|
||||||
log = $".[{tag}] {v}";
|
log = $".[{tag}] {v}";
|
||||||
string taglower = tag.ToLower();
|
string taglower = tag.ToLower();
|
||||||
@ -36,25 +44,24 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
Debug.Break();
|
Debug.Break();
|
||||||
}
|
}
|
||||||
|
public sealed override void ProfilerMarkBegin(int id)
|
||||||
public override void ProfilerMarkBegin(int id)
|
|
||||||
{
|
{
|
||||||
_profilerMarkers[id].Begin();
|
_profilerMarkers[id].Begin();
|
||||||
}
|
}
|
||||||
|
public sealed override void ProfilerMarkEnd(int id)
|
||||||
public override void ProfilerMarkEnd(int id)
|
|
||||||
{
|
{
|
||||||
_profilerMarkers[id].End();
|
_profilerMarkers[id].End();
|
||||||
}
|
}
|
||||||
|
protected sealed override void OnDelProfilerMark(int id)
|
||||||
protected override void OnDelProfilerMark(int id)
|
|
||||||
{
|
{
|
||||||
_profilerMarkers[id] = default;
|
_profilerMarkers[id] = default;
|
||||||
}
|
}
|
||||||
|
protected sealed override void OnNewProfilerMark(int id, string name)
|
||||||
protected override void OnNewProfilerMark(int id, string name)
|
|
||||||
{
|
{
|
||||||
if (id >= _profilerMarkers.Length) Array.Resize(ref _profilerMarkers, _profilerMarkers.Length << 1);
|
if (id >= _profilerMarkers.Length)
|
||||||
|
{
|
||||||
|
Array.Resize(ref _profilerMarkers, _profilerMarkers.Length << 1);
|
||||||
|
}
|
||||||
_profilerMarkers[id] = new ProfilerMarker(ProfilerCategory.Scripts, name);
|
_profilerMarkers[id] = new ProfilerMarker(ProfilerCategory.Scripts, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user