public void doRedo() { if (commandRedoList.Count > 0) { int id = commandRedoList.Count - 1; UndoCommandCenter temp = commandRedoList[id]; temp.RedoFunction(); commandUndoList.Add(temp); commandRedoList.RemoveAt(id); } }
public void doUndo() { if (commandUndoList.Count > 0) { int id = commandUndoList.Count - 1; UndoCommandCenter temp = commandUndoList[id]; Debug.Log(temp.undoProperty); Debug.Log(temp.index1); Debug.Log(temp.modifiedObject.name); temp.UndoFunction(); commandRedoList.Add(temp); commandUndoList.RemoveAt(id); } }
public void OnPropertyChange(bool index) { // Debug.Log("working"); var obj = states.Find(x => x.GetComponent <Links>().BoxActive); if (obj != null) { UndoCommandCenter temp = new UndoCommandCenter(); temp.undoProperty = UndoType.UpdateProperty; var objectLink = obj.GetComponent <Links>(); int _index = (int)objectLink.Property; temp.property = objectLink.Property; temp.modifiedObject = objectLink.propertyBoxes[_index]; var objectText = objectLink.propertyBoxes[_index].transform.Find("TextValue").GetComponent <Text>(); var increment = index ? 1 : -1; switch (_index) { case 0: temp.index1 = objectLink.Idle; objectLink.Idle += increment; temp.index2 = objectLink.Idle; break; case 1: temp.index1 = objectLink.Attack; objectLink.Attack += increment; temp.index2 = objectLink.Attack; break; case 2: temp.index1 = objectLink.Dodge; objectLink.Dodge += increment; temp.index2 = objectLink.Dodge; break; } objectText.text = (Convert.ToInt32(objectText.text) + increment).ToString(); UndoHandler.commandUndoList.Add(temp); UndoHandler.commandRedoList.Clear(); } }
public void OnDrop(PointerEventData eventData) { if (!item) { if (_LibraryType == LibraryType.ChainLibrary) { List <Transform> list = new List <Transform>(); for (int i = 0; i < transform.parent.childCount; i++) { list.Add(transform.parent.GetChild(i)); } var slot = GameObject.Instantiate(gameObject); slot.transform.SetParent(transform.parent); UndoCommandCenter temp = new UndoCommandCenter(); GameObject clone; if (dragHandeler.itemBeingDragged.transform.parent.GetComponent <Slot>()._LibraryType == LibraryType.ChainLibrary) { clone = dragHandeler.itemBeingDragged; temp.undoProperty = UndoType.SwapLink; temp.index1 = list.IndexOf(clone.transform.parent.transform); } else { clone = GameObject.Instantiate(dragHandeler.itemBeingDragged); temp.undoProperty = UndoType.CreateLink; temp.index1 = list.IndexOf(gameObject.transform); } clone.GetComponent <Links>().State = dragHandeler.itemBeingDragged.GetComponent <Links>().State; GameObject.FindGameObjectWithTag("EditorController").GetComponent <EditorController>().states.Add(clone); clone.transform.SetParent(transform); clone.transform.GetComponent <CanvasGroup>().blocksRaycasts = true; var dragState = clone.GetComponent <Links>().State; temp.modifiedObject = clone; temp.state = clone.GetComponent <Links>().State; var index = list.IndexOf(gameObject.transform); temp.index2 = index; ChainInspector.Add(index, clone); UndoHandler.commandUndoList.Add(temp); UndoHandler.commandRedoList.Clear(); if (dragState == LinkState.Think || dragState == LinkState.Watch) { clone.transform.Find("GoToDisplay").gameObject.SetActive(true); } } else { dragHandeler.itemBeingDragged.transform.Find("GoToDisplay").gameObject.SetActive(false); //ChainInspector.Remove(dragHandeler.itemBeingDragged); } ExecuteEvents.ExecuteHierarchy <IHasChanged>(gameObject, null, (x, y) => x.HasChanged()); } }