Exemple #1
0
        void OpenSaveGraphWindow(object mousePositionObject)
        {
            Vector2 mousePosition = (Vector2)mousePositionObject;

            if (!data.CheckHasEntranceNode())
            {
                EditorUtility.DisplayDialog("没有入口节点", "技能当中没有入口节点", "ok");
                return;
            }

            try
            {
                int newGraphId = PersistenceTool.GetNewGraphId();
                PopupWindow.Show(new Rect(mousePosition + position.position, new Vector2(500, 0)), new SaveGraphPopupWindow(
                                     newGraphId, (id, graphName, description) =>
                {
                    data.graphId          = id;
                    data.graphName        = graphName;
                    data.graphDescription = description;
                    PersistenceTool.SaveGraph(data);
                }));
            }
            catch
            {
            }
        }
Exemple #2
0
        public override void OnGUI(Rect rect)
        {
            GUILayout.Label("载入行为图", Utility.GetGuiStyle("Title"));
            GUILayout.Space(10);

            List <GraphBaseInfo> graphBaseInfoList = PersistenceTool.LoadGraphBaseInfoList();

            if (graphBaseInfoList == null || graphBaseInfoList.Count == 0)
            {
                GUILayout.Label("没有图可以载入", Utility.GetGuiStyle("LoadSkillHint"));
                return;
            }

            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            for (int i = 0; i < graphBaseInfoList.Count; i++)
            {
                GraphBaseInfo graphBaseInfo = graphBaseInfoList[i];
                if (GUILayout.Button(string.Format("{0}.{1}    {2}", graphBaseInfo.graphId, graphBaseInfo.graphName,
                                                   graphBaseInfo.graphDescription)))
                {
                    if (loadCallback != null)
                    {
                        loadCallback(graphBaseInfo.graphId);

                        if (EditorWindow.focusedWindow != null)
                        {
                            editorWindow.Close();
                        }
                        break;
                    }
                }
            }

            GUILayout.EndScrollView();
        }
Exemple #3
0
 void SaveCurrentGraph(object mousePositionObject)
 {
     if (data.CheckHasEntranceNode())
     {
         PersistenceTool.SaveGraph(data);
     }
     else
     {
         EditorUtility.DisplayDialog("没有入口节点", "技能当中没有入口节点", "ok");
     }
 }
Exemple #4
0
        public override void OnGUI(Rect rect)
        {
            GUILayout.Label("删除行为图", Utility.GetGuiStyle("DeleteFileTitle"));
            GUILayout.Space(10);

            List <GraphBaseInfo> graphBaseInfoList = PersistenceTool.LoadGraphBaseInfoList();

            if (graphBaseInfoList == null)
            {
                GUILayout.Label("没有图可以删除", Utility.GetGuiStyle("LoadSkillHint"));
                return;
            }

            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            for (int i = 0; i < graphBaseInfoList.Count; i++)
            {
                GraphBaseInfo graphBaseInfo = graphBaseInfoList[i];
                if (GUILayout.Button(string.Format("删除   {0}.{1}    {2}", graphBaseInfo.graphId, graphBaseInfo.graphName,
                                                   graphBaseInfo.graphDescription)))
                {
                    if (EditorUtility.DisplayDialog("删除行为图",
                                                    string.Format("是否删除行为图 {0}:{1} \n 描述:{2}", graphBaseInfo.graphId, graphBaseInfo.graphName,
                                                                  graphBaseInfo.graphDescription), "ok"))
                    {
                        if (deleteCallback != null)
                        {
                            deleteCallback(graphBaseInfo.graphId);

                            if (EditorWindow.focusedWindow != null)
                            {
                                editorWindow.Close();
                            }

                            break;
                        }
                    }
                }
            }

            GUILayout.EndScrollView();
        }
Exemple #5
0
        void OpenGraphLoadWindow(object mousePositionObject)
        {
            Vector2 mousePosition = (Vector2)mousePositionObject;

            try
            {
                PopupWindow.Show(new Rect(mousePosition + position.position, new Vector2(500, 0)), new LoadGraphPopupWindow(
                                     loadGraphId =>
                {
                    Reset();
                    data = PersistenceTool.LoadGraph(this, loadGraphId);

                    //做一些载入完成的初始化工作
                    data.OnLoadFinish();

                    //检查连线的合法性
                    data.CheckAllNodeConnection();
                }));
            }
            catch
            {
            }
        }