//OnAdd private void OnAdd(HistoryActionContainer actionContainer) { HistoryButton button = Instantiate(buttonPrefab, content); button.Init(actionContainer); undoLookUp.Add(actionContainer, button); button.actionContainer = actionContainer; }
public void Init(HistoryActionContainer container) { actionContainer = container; textName.text = container.action.Result.ToString(); imageColor = image.color; Show(); gameObject.SetActive(true); }
public void Redo(HistoryActionContainer actionContainer) { undoList.Add(actionContainer); redoList.Remove(actionContainer); actionContainer.action.Result.Redo(); if (OnRedo != null) { OnRedo.Invoke(actionContainer); } }
public void Redo() { if (redoList.Count <= 0) { return; } HistoryActionContainer actionContainer = redoList[redoList.Count - 1]; Redo(actionContainer); }
public void AddAction(Action action) { HistoryActionContainer actionContainer = new HistoryActionContainer(action); undoList.Add(actionContainer); if (OnAdd != null) { OnAdd.Invoke(actionContainer); } ClearRedoList(); }
public void OrderedRedo(HistoryActionContainer actionContainer) { //Find where it is on the list. int index = redoList.IndexOf(actionContainer); int lastIndex = redoList.Count - 1; List <HistoryActionContainer> cacheList = new List <HistoryActionContainer>(redoList); for (int i = lastIndex; i > index - 1; i--) { Redo(cacheList[i]); } OnHistoryChanged.SafeInvoke(); }
//On undo private void HistoryManager_OnUndo(HistoryActionContainer action) { undoLookUp[action].Hide(); }
//Onredo private void HistoryManager_OnRedo(HistoryActionContainer action) { undoLookUp[action].Show(); }