#if UNITY_EDITOR using System.Diagnostics; using System.Collections.ObjectModel; using System.Collections.Generic; namespace UnityAtoms { public static class StackTraces { private static Dictionary> _stackTracesById = new Dictionary>(); 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 GetStackTraces(int id) { if (!_stackTracesById.ContainsKey(id)) { _stackTracesById.Add(id, new ObservableCollection()); } else if (_stackTracesById[id] == null) { _stackTracesById[id] = new ObservableCollection(); } return _stackTracesById[id]; } } } #endif