public void swapUndo() { //Debug.Log("swapUndo:" + objectToUndo.name); //Debug.Log(oppositeUndoMemento == null); if (oppositeUndoMemento == null) { oppositeUndoMemento = createMementoFunc(); oppositeUndoMemento.save(objectToUndo); } undoMemento.restore(objectToUndo); var lTemp = undoMemento; undoMemento = oppositeUndoMemento; oppositeUndoMemento = lTemp; //Debug.Log(oppositeUndoMemento == null); }
public UndoObject(Object pObjectToUndo, System.Func<UndoMemento> pCreateMementoFunc) { //Debug.Log("UndoObject:" + pObjectToUndo.name); createMementoFunc = pCreateMementoFunc; objectToUndo = pObjectToUndo; undoMemento = createMementoFunc(); undoMemento.save(objectToUndo); oppositeUndoMemento = null; }