mirror of
https://github.com/unity-atoms/unity-atoms.git
synced 2025-01-26 01:48:25 -05:00
70f8130797
* Add stack trace toggled via user prefs * Add docs regarding preferences * Rename color getter functions * Fix minior order of execution bug * Use GUID + improved styling of detailed stack view * - Changed the AddStackTrace method to be conditional (from one of your initial suggestions). - Removed the implicit conversion operator in StackTraceEntry and is instead using ToString explicitly when needed. - Improved implementation of GetFirstLine - Simplified Equals implementation of the StackTraceEntry class
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
|