public static void EndUndoGroup() { if (m_undoStack.Count > 0) { BTUndoGroup oldGroup = m_undoStack.Peek() as BTUndoGroup; if (oldGroup != null && oldGroup.IsOpen) { if (oldGroup.IsEmpty) { m_undoStack.Pop(); } else { oldGroup.Close(); } } } }
public static void RegisterUndo(BTUndoState undoState) { if (undoState != null && undoState.CanUndo) { if (m_undoStack.Count > 0) { BTUndoGroup topGroup = m_undoStack.Peek() as BTUndoGroup; if (topGroup != null && topGroup.IsOpen) { topGroup.AddUndoState(undoState); m_redoStack.Clear(); return; } } m_undoStack.Push(undoState); m_redoStack.Clear(); } }
public static void BeginUndoGroup(string title) { if (m_undoStack.Count > 0) { BTUndoGroup oldGroup = m_undoStack.Peek() as BTUndoGroup; if (oldGroup != null && oldGroup.IsOpen) { Debug.LogWarningFormat("You have to call BTUndoSystem.EndUndoGroup before begining a new group. Old group is '{0}', new group is '{1}'", oldGroup.Title, title); if (oldGroup.IsEmpty) { m_undoStack.Pop(); } else { oldGroup.Close(); } } } BTUndoGroup group = new BTUndoGroup(title); m_undoStack.Push(group); }