private void CreateViews() { if (m_mainWindow != null) { m_mainView = new MainView(); m_propertyView = new PropertyView(); } else { m_mainWindow = EditorWindow.GetWindow <NodeEditorWindow>() as NodeEditorWindow; } }
public virtual void UpdateNodeGUI(Event _e, Rect _viewRect, GUISkin _skin) { NodeEditorWindow curWindow = EditorWindow.GetWindow <NodeEditorWindow>() as NodeEditorWindow; if (curWindow != null) { int index = curWindow.GetCurrentGraph().m_nodes.IndexOf(this); if (index == 0) { GUI.color = Color.blue; } else { GUI.color = Color.white; } m_nodeRect = GUI.Window(index, m_nodeRect, DoMyWindow, m_nodeName); } ProcessEvents(Event.current); GUI.color = Color.white; foreach (NodeInput input in m_inputs) { if (input != null) { input.UpdateGUI(this, curWindow); } } foreach (NodeOutput output in m_outputs) { if (output != null) { output.UpdateGUI(this, curWindow); } } if (m_parentGraph.isDragging) { UpdateNodeIndex(this); if (m_inputs[0] != null && m_inputs[0].m_connectedTo != null) { m_inputs[0].m_connectedTo.m_holderNode.UpdateNodeIndex(m_inputs[0].m_connectedTo.m_holderNode); } m_parentGraph.isDragging = false; } EditorUtility.SetDirty(this); }
public static void UnloadGraph() { NodeEditorWindow curWindow = EditorWindow.GetWindow <NodeEditorWindow>() as NodeEditorWindow; if (curWindow != null) { curWindow.SetCurrentGraph(null); } else { EditorUtility.DisplayDialog("Error Something Worng", "Something went wrong in getting the current window", "Ok"); } curWindow.Repaint(); }
public virtual void UpdateGUI(BaseNode _node, NodeEditorWindow _curWindow) { if (GUI.Button(m_IORect, new GUIContent(""))) { NodeGraph graph = _curWindow.GetCurrentGraph(); Event e = Event.current; if (e.button == 1) { graph.SetIsMakingConnection(false); graph.m_connectionFrom = null; ProcessContextMenu(e, graph); return; } if (graph.GetIsMakingConnection() && graph.GetConnectionType() != m_type) { if (m_connectedTo != null) { m_connectedTo.m_isOccupied = false; m_connectedTo.m_connectedTo = null; } Debug.Log("Connection made"); m_isOccupied = true; m_connectedTo = graph.m_connectionFrom; m_connectedTo.m_isOccupied = true; m_connectedTo.m_isOccupied = true; m_connectedTo.m_connectedTo = this; graph.SetIsMakingConnection(false); graph.m_connectionFrom = null; } else if (!_curWindow.GetCurrentGraph().GetIsMakingConnection()) { _curWindow.GetCurrentGraph().SetIsMakingConnection(true); _curWindow.GetCurrentGraph().SetConnectionType(m_type); _curWindow.GetCurrentGraph().SetConnectionStart(m_IORect.center); _curWindow.GetCurrentGraph().m_connectionFrom = this; } AssetDatabase.AddObjectToAsset(this, m_holderNode); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } }
public static void LoadGraph() { NodeGraph curGraph = null; string pathToLoad = EditorUtility.OpenFilePanel("Load BehaviourTree", "Asset/", ""); int appPathLen = Application.dataPath.Length; string fullPath = pathToLoad.Substring(appPathLen - 6); curGraph = AssetDatabase.LoadAssetAtPath(fullPath, typeof(NodeGraph)) as NodeGraph; if (curGraph != null) { NodeEditorWindow curWindow = EditorWindow.GetWindow <NodeEditorWindow>() as NodeEditorWindow; if (curWindow != null) { curWindow.SetCurrentGraph(curGraph); } } }
public override void UpdateGUI(BaseNode _node, NodeEditorWindow _curWindow) { if (_node.GetNodeType() != NodeType.ROOT_NODE) { Rect nodeRect = _node.GetNodeRect(); Rect tmp = new Rect(); tmp.width = 13f; tmp.height = 13f; float offset = 5f; float centerOfNode = nodeRect.x + (nodeRect.width / 2); float centerOfOutput = tmp.width / 2; tmp.x = centerOfNode - centerOfOutput; tmp.y = nodeRect.y - (tmp.height + offset); m_IORect = tmp; base.UpdateGUI(_node, _curWindow); } }
public virtual void InitNode() { NodeEditorWindow curWindow = EditorWindow.GetWindow <NodeEditorWindow>() as NodeEditorWindow; m_inputs = new List <NodeInput>(); index = curWindow.GetCurrentGraph().m_nodes.Count; if (m_nodeType != NodeType.ROOT_NODE) { NodeInput input = new NodeInput(); input.m_holderNode = this; m_inputs.Add(input); } m_outputs = new List <NodeOutput>(); NodeOutput output = new NodeOutput(); output.m_holderNode = this; m_outputs.Add(output); }