//====================================================== //## TODO //====================================================== public void CopyNode() { if (selectNode == null) { return; } if (selectNode.myData.type == NodeType.STATE) { AdvancedStateMachine.AdvancedState state = new AdvancedStateMachine.AdvancedState(); //state.ID = "copy_" + selectNode.myData.state.ID; Target.advancedStates.Add(state); InitializePropertyData(); InitializeStateNames(); //serializedObject.Update(); //serializedObject.Co //SerializedProperty test2 = propertyStates.GetEndProperty(); //test2 = propertyStates.GetArrayElementAtIndex(FindStateIndexByNode(selectNode)).Copy(); serializedObject.ApplyModifiedProperties(); EditorNode <NodeData> node = CreateStateNode(state, new Vector2(selectNode.rect.position.x + 15, selectNode.rect.position.y + 15), state.ID); SelectNode(node); } else if (selectNode.myData.type == NodeType.TRANSITION) { } }
public EditorNode <NodeData> FindNodeByState(AdvancedStateMachine.AdvancedState state) { if (state == null) { return(null); } if (state.ID == null) { return(null); } for (int i = 0; i < editorNodes.Count; i++) { if (editorNodes[i].myData.type != NodeType.STATE) { continue; } if (editorNodes[i].myData.state.ID == state.ID) { return(editorNodes[i]); } } return(null); }
private void InitializeNode() { if (editorNodes == null) { editorNodes = new List <EditorNode <NodeData> >(); } editorNodes.Clear(); if (selected == null) { return; } for (int i = 0; i < selected.advancedStates.Count; i++) { AdvancedStateMachine.AdvancedState state = selected.advancedStates[i]; CreateStateNode(state, new Vector2(30.0f + (i * 10.0f), 30.0f + (i * 10.0f)), state.ID); } for (int i = 0; i < Transitions.Length; i++) { CreateTransitionNode(Transitions[i], new Vector2(60.0f + (i * 10.0f), 30.0f + (i * 10.0f)), Transitions[i].ID); } }
private EditorNode <NodeData> CreateStateNode(AdvancedStateMachine.AdvancedState state, Vector2 position, string title) { EditorNode <NodeData> node = new EditorNode <NodeData>(new NodeData(NodeType.STATE, state, null) , 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 4", (GUIStyle)"flow node hex 4 on" , OnStateNodeGenericMenu); editorNodes.Add(node); return(node); }
public void SelectNodeByState(AdvancedStateMachine.AdvancedState state) { for (int i = 0; i < editorNodes.Count; i++) { if (editorNodes[i].myData.type == NodeType.STATE) { if (editorNodes[i].myData.state.ID == state.ID) { SelectNode(editorNodes[i]); return; } } } }
//TODO : 동일한 ID 입력에 대한 예외처리 해주 public void CreateState(Vector2 position) { AdvancedStateMachine.AdvancedState state = new AdvancedStateMachine.AdvancedState(); //state.ID = "New State" + Target.advancedStates.Count; Target.advancedStates.Add(state); InitializePropertyData(); InitializeStateNames(); EditorNode <NodeData> node = CreateStateNode(state, position, state.ID); SelectNode(node); SaveData(); }
public NodeData(NodeType type, AdvancedStateMachine.AdvancedState state, AdvancedStateMachine.AdvancedTransition transition) { this.type = type; this.state = state; this.transition = transition; }