mirror of
https://github.com/unity-atoms/unity-atoms.git
synced 2025-01-26 18:08:27 -05:00
39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
|
#if UNITY_EDITOR
|
|||
|
using System.Diagnostics;
|
|||
|
using System.Collections.ObjectModel;
|
|||
|
using System.Collections.Generic;
|
|||
|
|
|||
|
namespace UnityAtoms
|
|||
|
{
|
|||
|
public static class StackTraces
|
|||
|
{
|
|||
|
private static Dictionary<int, ObservableCollection<StackTraceEntry>> _stackTracesById = new Dictionary<int, ObservableCollection<StackTraceEntry>>();
|
|||
|
|
|||
|
[Conditional("UNITY_EDITOR")]
|
|||
|
public static void AddStackTrace(int id, StackTraceEntry stackTrace)
|
|||
|
{
|
|||
|
if (AtomPreferences.IsDebugModeEnabled)
|
|||
|
{
|
|||
|
GetStackTraces(id).Insert(0, stackTrace);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public static void ClearStackTraces(int id) => GetStackTraces(id).Clear();
|
|||
|
|
|||
|
public static ObservableCollection<StackTraceEntry> GetStackTraces(int id)
|
|||
|
{
|
|||
|
if (!_stackTracesById.ContainsKey(id))
|
|||
|
{
|
|||
|
_stackTracesById.Add(id, new ObservableCollection<StackTraceEntry>());
|
|||
|
}
|
|||
|
else if (_stackTracesById[id] == null)
|
|||
|
{
|
|||
|
_stackTracesById[id] = new ObservableCollection<StackTraceEntry>();
|
|||
|
}
|
|||
|
|
|||
|
return _stackTracesById[id];
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endif
|