private EditorNode <NodeData> CreateTransitionNode(AdvancedTransition transition, Vector2 position, string title) { EditorNode <NodeData> node = new EditorNode <NodeData>(new NodeData(NodeType.TRANSITION, null, transition) , editorNodes.Count , new Rect(position.x - (NODE_WIDTH * 0.5f), position.y - (NODE_HEIGHT * 0.5f), NODE_WIDTH, NODE_HEIGHT) , title , (GUIStyle)"flow node hex 0", (GUIStyle)"flow node hex 0 on" , null); editorNodes.Add(node); return(node); }
public void SelectNodeByTransition(AdvancedTransition transition) { for (int i = 0; i < editorNodes.Count; i++) { if (editorNodes[i].myData.type == NodeType.TRANSITION) { if (editorNodes[i].myData.transition.ID == transition.ID) { SelectNode(editorNodes[i]); return; } } } }
public void Initialize(SerializedProperty data, EditorNode <AdvancedStateMachineEditorWindow.NodeData> node) { if (data == null || node == null) { return; } this.node = node; transitionProperty = data; transition = node.myData.transition; popupList = AdvancedStateMachineEditorWindow.Instance.stateNames; popupIndex = FindTransitionIndex(); }
private void ClickListItemMoveUp() { if (selectedItem == null || transitions == null || transitions.Count <= 0) { return; } int selectedIndex = selectedItem.index; if (selectedIndex > 0) { ListItem <AdvancedTransition> t = transitions[selectedIndex]; transitions[selectedIndex] = transitions[selectedIndex - 1]; transitions[selectedIndex - 1] = t; AdvancedTransition temp = node.myData.state.Transition.ChildTransitions[selectedIndex]; node.myData.state.Transition.ChildTransitions[selectedIndex] = node.myData.state.Transition.ChildTransitions[selectedIndex - 1]; node.myData.state.Transition.ChildTransitions[selectedIndex - 1] = temp; SelectListItem(transitions[selectedIndex - 1]); } else { ListItem <AdvancedTransition> t = transitions[selectedIndex]; transitions[selectedIndex] = transitions[transitions.Count - 1]; transitions[transitions.Count - 1] = t; AdvancedTransition temp = node.myData.state.Transition.ChildTransitions[selectedItem.index]; node.myData.state.Transition.ChildTransitions[selectedItem.index] = node.myData.state.Transition.ChildTransitions[transitions.Count - 1]; node.myData.state.Transition.ChildTransitions[transitions.Count - 1] = temp; SelectListItem(transitions[transitions.Count - 1]); } RefreshListItemIndex(); EditorUtility.SetDirty(AdvancedStateMachineEditorWindow.Target); }
public EditorNode <NodeData> FindNodeByTransition(AdvancedTransition transition) { if (transition == null) { return(null); } for (int i = 0; i < editorNodes.Count; i++) { if (editorNodes[i].myData.type != NodeType.TRANSITION) { continue; } if (editorNodes[i].myData.transition.ID == transition.ID) { return(editorNodes[i]); } } return(null); }
public NodeData(NodeType type, AdvancedState state, AdvancedTransition transition) { this.type = type; this.state = state; this.transition = transition; }