void OnUndoSelectionChange(IEnumerable <object> selectedItems) { if (m_HistoryListView.selectedItem == null) { return; } HistoryItem item = (HistoryItem)m_HistoryListView.selectedItem; int actionsRequired = Math.Abs(item.index - m_UndoCursor); if (item.type == HistoryType.Undo || item.type == HistoryType.None) { for (var i = 0; i < actionsRequired; i++) { EditorUtility.DisplayProgressBar("Undo", "Undoing selected actions", (float)i / actionsRequired); Undo.PerformUndo(); } } else { for (var i = 0; i < actionsRequired; i++) { EditorUtility.DisplayProgressBar("Undo", "Redoing selected actions", (float)i / actionsRequired); Undo.PerformRedo(); } } EditorUtility.ClearProgressBar(); }