示例#1
0
        public static void Draw(Rect viewRect)
        {
            GUI.Box(viewRect, "");


            GUILayout.BeginArea(viewRect);
            {
                GUILayout.BeginHorizontal();
                GUILayout.Box("", GUILayout.Height(viewRect.height), GUILayout.Width(2));
                if (GUILayout.Button("NEW", GUILayout.Height(viewRect.height), GUILayout.Width(viewRect.height)))
                {
                    NodePopupWindow.Init();
                }
                if (GUILayout.Button("OPEN", GUILayout.Height(viewRect.height), GUILayout.Width(viewRect.height)))
                {
                    DialogGraph.LoadGraph();
                }
                if (GUILayout.Button("RESET POSITION", GUILayout.Height(viewRect.height), GUILayout.Width(viewRect.height * 3)))
                {
                    DialogEditor.Instance.TryResetViewToStartNode();
                }
                if (GUILayout.Button("SAVE", GUILayout.Height(viewRect.height), GUILayout.Width(viewRect.height * 3)))
                {
                    AssetDatabase.SaveAssets();
                    AssetDatabase.Refresh();
                }
                GUILayout.FlexibleSpace();
                GUILayout.Box(Title, GUILayout.Height(viewRect.height), GUILayout.Width(viewRect.height * 4));
                GUILayout.EndHorizontal();
            }
            GUILayout.EndArea();
        }
示例#2
0
        public void OnGUI()
        {
            GUILayout.Space(20);
            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            EditorGUILayout.LabelField("New Graph", EditorStyles.boldLabel, GUILayout.Width(80));
            graphName = EditorGUILayout.TextField(graphName);
            GUILayout.Space(20);
            GUILayout.EndHorizontal();

            GUILayout.Space(6);
            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            if (GUILayout.Button("Create"))
            {
                if (!string.IsNullOrEmpty(graphName) && !graphName.Equals("Enter a name ..."))
                {
                    DialogGraph.CreateDialogGraph(graphName);
                    Instance.Close();
                }
                else
                {
                    EditorUtility.DisplayDialog("Error", "Enter a valid name", "OK");
                }
            }
            GUILayout.Space(10);
            if (GUILayout.Button("Cancel"))
            {
                Instance.Close();
            }
            GUILayout.Space(20);
            GUILayout.EndHorizontal();
            GUILayout.Space(20);
            Repaint();
        }
示例#3
0
        public static void CreateDialogGraph(string name)
        {
            DialogGraph currentGraph = ScriptableObject.CreateInstance <DialogGraph>();

            if (currentGraph != null)
            {
                currentGraph.Name = name;
                currentGraph.Initialize();
                AssetDatabase.CreateAsset(currentGraph, @"Assets/Resources/Database/" + name + ".asset");
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
                DialogEditor currentWindow = EditorWindow.GetWindow <DialogEditor>();
                if (currentWindow != null)
                {
                    currentWindow.CurrentGraph = currentGraph;
                }
                else
                {
                    ErrorMessage("Dialog editor window is lost, reopen it");
                }
            }
        }