mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 01:54:35 +08:00
Add debug feature
This commit is contained in:
parent
9509da8b95
commit
5f668bb516
8
src/Debug.meta
Normal file
8
src/Debug.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 853912b6db8b61c40a9c2d74a2759f94
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ed7ff62966b45141b388716e91dfac0
|
||||
guid: 0c0c879077450ac479afb5b86efc5a93
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
56
src/Debug/UnityDebugService.cs
Normal file
56
src/Debug/UnityDebugService.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using Unity.Profiling;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DCFApixels.DragonECS.Unity
|
||||
{
|
||||
public class UnityDebugService : DebugService
|
||||
{
|
||||
public static void Set()
|
||||
{
|
||||
DebugService.Set<UnityDebugService>();
|
||||
}
|
||||
|
||||
private ProfilerMarker[] _profilerMarkers = new ProfilerMarker[64];
|
||||
|
||||
public override void Print(string tag, object v)
|
||||
{
|
||||
string log = $"[{tag}] {v}";
|
||||
string taglower = tag.ToLower();
|
||||
if (taglower.Contains("warning"))
|
||||
{
|
||||
Debug.LogWarning(log);
|
||||
return;
|
||||
}
|
||||
if (taglower.Contains("error"))
|
||||
{
|
||||
Debug.LogError(log);
|
||||
return;
|
||||
}
|
||||
Debug.Log(log);
|
||||
}
|
||||
|
||||
public override void ProfileMarkBegin(int id)
|
||||
{
|
||||
_profilerMarkers[id].Begin();
|
||||
}
|
||||
|
||||
public override double ProfileMarkEnd(int id)
|
||||
{
|
||||
_profilerMarkers[id].End();
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected override void OnDelMark(int id)
|
||||
{
|
||||
_profilerMarkers[id] = default;
|
||||
}
|
||||
|
||||
protected override void OnNewMark(int id, string name)
|
||||
{
|
||||
if (id >= _profilerMarkers.Length) Array.Resize(ref _profilerMarkers, _profilerMarkers.Length << 1);
|
||||
_profilerMarkers[id] = new ProfilerMarker(ProfilerCategory.Scripts, name);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
11
src/Debug/UnityDebugService.cs.meta
Normal file
11
src/Debug/UnityDebugService.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b58ebee63dda32544a67f1917d94f40c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d334d67cff28704c94924d2e6c8df84
|
||||
guid: 45a14256c767cab49879fb8aa88ec193
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
Loading…
Reference in New Issue
Block a user