示例#1
0
        public static void CreateGraph(string _wantedName, string _path)
        {
            NodeGraph curGraph = ScriptableObject.CreateInstance <NodeGraph>() as NodeGraph;

            if (curGraph != null)
            {
                curGraph.SetGraphName(_wantedName);
                curGraph.InitGraph();

                if (string.IsNullOrEmpty(_path))
                {
                    _path = "Assets/BTNodeEditor/Database";
                }

                AssetDatabase.CreateAsset(curGraph, _path + "/" + curGraph.GetGraphName() + ".asset");
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();

                NodeEditorWindow curWindow = EditorWindow.GetWindow <NodeEditorWindow>() as NodeEditorWindow;
                if (curWindow != null)
                {
                    curWindow.SetCurrentGraph(curGraph);
                    //CreateNode(curGraph, NodeType.ROOT_NODE, curWindow.GetMainView().GetViewRect().center);
                }
                else
                {
                    EditorUtility.DisplayDialog("Error Something Worng", "Wasnt able to the set current graph variable for the NodeEditorWindow", "Ok");
                }
            }
            else
            {
                EditorUtility.DisplayDialog("Error Something Worng", "Wasnt able to create a new graph. See ur friendly programmer", "Ok");
            }
        }
示例#2
0
        public virtual void UpdateView(Rect _editorRect, Rect _percentageRect, Event _e, NodeGraph _nodeGraph)
        {
            m_viewRect = new Rect(_editorRect.x * _percentageRect.x,
                                  _editorRect.y * _percentageRect.y,
                                  _editorRect.width * _percentageRect.width,
                                  _editorRect.height * _percentageRect.height);

            m_currGraph = _nodeGraph;

            if (m_currGraph != null)
            {
                m_viewTitle = m_currGraph.GetGraphName();
            }
            else
            {
                m_viewTitle = "No Graph";
            }

            GUI.Box(m_viewRect, m_viewTitle, GetViewSkin().GetStyle("BTNE Node Editor"));
        }