diff --git a/Source/Editor/Undo/Undo.cs b/Source/Editor/Undo/Undo.cs index 23d6b2be0..a5c5a684f 100644 --- a/Source/Editor/Undo/Undo.cs +++ b/Source/Editor/Undo/Undo.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Linq; using FlaxEditor.History; using FlaxEditor.Utilities; +using FlaxEngine; using FlaxEngine.Collections; namespace FlaxEditor @@ -38,9 +39,6 @@ namespace FlaxEditor /// /// Gets the undo operations stack. /// - /// - /// The undo operations stack. - /// public HistoryStack UndoOperationsStack { get; } /// @@ -136,8 +134,11 @@ namespace FlaxEditor { if (!Enabled) return; + Profiler.BeginEvent("Undo.RecordBegin"); _snapshots.Add(snapshotInstance, new UndoInternal(snapshotInstance, actionString)); + + Profiler.EndEvent(); } /// @@ -150,11 +151,10 @@ namespace FlaxEditor { if (!Enabled) return; + Profiler.BeginEvent("Undo.RecordEnd"); if (snapshotInstance == null) - { snapshotInstance = _snapshots.Last().Key; - } var action = _snapshots[snapshotInstance].End(snapshotInstance); _snapshots.Remove(snapshotInstance); @@ -178,6 +178,8 @@ namespace FlaxEditor UndoOperationsStack.Push(action); OnAction(action); } + + Profiler.EndEvent(); } /// @@ -233,8 +235,11 @@ namespace FlaxEditor { if (!Enabled) return; + Profiler.BeginEvent("Undo.RecordMultiBegin"); _snapshots.Add(snapshotInstances, new UndoMultiInternal(snapshotInstances, actionString)); + + Profiler.EndEvent(); } /// @@ -247,11 +252,10 @@ namespace FlaxEditor { if (!Enabled) return; + Profiler.BeginEvent("Undo.RecordMultiEnd"); if (snapshotInstance == null) - { snapshotInstance = (object[])_snapshots.Last().Key; - } var action = _snapshots[snapshotInstance].End(snapshotInstance); _snapshots.Remove(snapshotInstance); @@ -275,6 +279,8 @@ namespace FlaxEditor UndoOperationsStack.Push(action); OnAction(action); } + + Profiler.EndEvent(); } /// @@ -325,12 +331,10 @@ namespace FlaxEditor { if (action == null) throw new ArgumentNullException(); - if (!Enabled) return; UndoOperationsStack.Push(action); - OnAction(action); } @@ -341,11 +345,14 @@ namespace FlaxEditor { if (!Enabled || !CanUndo) return; + Profiler.BeginEvent("Undo.PerformUndo"); var action = (IUndoAction)UndoOperationsStack.PopHistory(); action.Undo(); OnUndo(action); + + Profiler.EndEvent(); } /// @@ -355,11 +362,14 @@ namespace FlaxEditor { if (!Enabled || !CanRedo) return; + Profiler.BeginEvent("Undo.PerformRedo"); var action = (IUndoAction)UndoOperationsStack.PopReverse(); action.Do(); OnRedo(action); + + Profiler.EndEvent(); } ///