コード例 #1
0
    public static void CreateNewGraph(string graphName)
    {
        NodeGraph currentGraph = (NodeGraph)ScriptableObject.CreateInstance <NodeGraph>();

        if (currentGraph != null)
        {
            currentGraph.graphName = graphName;
            currentGraph.InitGraph();

            AssetDatabase.CreateAsset(currentGraph, "Assets/Dialogue System/Resources/Database/" + graphName + ".asset");
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            NodeGraphWindow currentWindow = (NodeGraphWindow)EditorWindow.GetWindow <NodeGraphWindow>();

            if (currentWindow != null)
            {
                currentWindow.currentGraph = currentGraph;
            }

            CreateNode(currentWindow.currentGraph, NodeType.Start, new Vector2(104, 136));
            CreateNode(currentWindow.currentGraph, NodeType.End, new Vector2(307, 136));
        }
        else
        {
            EditorUtility.DisplayDialog("Graph Message", "No se pudo crear el Grapho", "OK");
        }
    }
コード例 #2
0
    public static void LoadGraph()
    {
        NodeGraph currentGraph = null;
        string    graphPath    = EditorUtility.OpenFilePanel("Load Graph", Application.dataPath + "/Dialogue System/Resources/Database/", "");

        if (graphPath != "")
        {
            int    appPathLen = Application.dataPath.Length;
            string finalPath  = graphPath.Substring(appPathLen - 6);

            currentGraph = (NodeGraph)AssetDatabase.LoadAssetAtPath(finalPath, typeof(NodeGraph));

            if (currentGraph != null)
            {
                NodeGraphWindow currentWindow = (NodeGraphWindow)EditorWindow.GetWindow <NodeGraphWindow>();

                if (currentWindow != null)
                {
                    currentWindow.currentGraph = currentGraph;
                }
            }
            else
            {
                EditorUtility.DisplayDialog("Graph Message", "No se pudo cargar el Grapho seleccionado", "OK");
            }
        }
    }
コード例 #3
0
    //Metodos Principales
    public static void InitEditorWindow()
    {
        currentWindow = EditorWindow.GetWindow <NodeGraphWindow>();
        currentWindow.titleContent = new GUIContent("Flow Chart");

        CreateViews();
    }
コード例 #4
0
    public static void UnloadGraph()
    {
        NodeGraphWindow currentWindow = (NodeGraphWindow)EditorWindow.GetWindow <NodeGraphWindow>();

        if (currentWindow != null)
        {
            currentWindow.currentGraph = null;
        }
    }
コード例 #5
0
 //Metodos extra
 static void CreateViews()
 {
     if (currentWindow != null)
     {
         currentWindow.propertyView = new NodePropertyView();
         currentWindow.toolView     = new ToolbarView();
         currentWindow.graphView    = new GraphView();
     }
     else
     {
         currentWindow = EditorWindow.GetWindow <NodeGraphWindow>();
     }
 }
コード例 #6
0
 public static void InitNodeEditor()
 {
     NodeGraphWindow.InitEditorWindow();
 }