Ejemplo n.º 1
0
        public static void ShowWindow()
        {
            BTEditorWindow bTreeEditorWindow = GetWindow(typeof(BTEditorWindow)) as BTEditorWindow;

            bTreeEditorWindow.titleContent   = new GUIContent("行为树编辑器");
            bTreeEditorWindow.mIsFirst       = true;
            bTreeEditorWindow.wantsMouseMove = true;
            bTreeEditorWindow.minSize        = new Vector2(600f, 500f);
            DontDestroyOnLoad(bTreeEditorWindow);

            BTEditorNodeFactory.Init();
        }
Ejemplo n.º 2
0
        public void ExportBinaryBTree()
        {
            if (mGraphDesigner == null || mGraphDesigner.mRootNode == null)
            {
                EditorUtility.DisplayDialog("Export Error", "未创建根节点", "ok");
                return;
            }
            Debugger.Log("exportBtree");
            TreeConfig _treeConfig = BTEditorNodeFactory.CreateTreeConfigFromBTreeGraphDesigner(mGraphDesigner);
            string     name        = mGraphDesigner.mRootNode.NodeName;

            BTEditorSerialization.ExportBinary(_treeConfig, name);
            EditorUtility.DisplayDialog("Export", "导出行为树配置成功:" + name, "ok");
        }
Ejemplo n.º 3
0
 //加载
 public void Load(BTEditorConfig _config)
 {
     mRootNode = BTEditorNodeFactory.CreateBTreeNodeDesignerFromConfig(_config.mRootNode)[0];
     mRootNode.SetEntryDisplay(true);
     if (_config.mDetachedNode != null)
     {
         mDetachedNodes = new List <BTNodeDesigner>();
         for (int i = 0; i < _config.mDetachedNode.Count; i++)
         {
             BTNodeDesigner _detachedNode = BTEditorNodeFactory.CreateBTreeNodeDesignerFromConfig(_config.mDetachedNode[i])[0];
             mDetachedNodes.Add(_detachedNode);
         }
     }
 }
Ejemplo n.º 4
0
        public void SaveBTree()
        {
            if (mGraphDesigner == null || mGraphDesigner.mRootNode == null)
            {
                EditorUtility.DisplayDialog("Save Error", "未创建根节点", "ok");
                return;
            }
            string text = EditorUtility.SaveFilePanel("Save Behavior Tree", BTEditorUtility.editorPath + "Config", mGraphDesigner.mRootNode.NodeName, "xml");

            if (text.Length != 0 && Application.dataPath.Length < text.Length)
            {
                Debugger.Log("saveBTree");
                BTEditorConfig _config = BTEditorNodeFactory.CreateBtreeEditorConfigFromGraphDesigner(mGraphDesigner);
                BTEditorSerialization.WirteXMLAtPath(_config, text);
                EditorUtility.DisplayDialog("Save", "保存行为树编辑器成功:" + text, "ok");
            }
        }
Ejemplo n.º 5
0
        public void ExportXMLBTree()
        {
            if (mGraphDesigner == null || mGraphDesigner.mRootNode == null)
            {
                EditorUtility.DisplayDialog("Export Error", "未创建根节点", "ok");
                return;
            }
            string text = EditorUtility.SaveFilePanel("Save Behavior Tree", BTEditorSerialization.exportConfigPath, mGraphDesigner.mRootNode.NodeName, "xml");

            if (text.Length != 0 && Application.dataPath.Length < text.Length)
            {
                Debugger.Log("exportBtree");
                TreeConfig _treeConfig = BTEditorNodeFactory.CreateTreeConfigFromBTreeGraphDesigner(mGraphDesigner);

                BTEditorSerialization.ExportXML(_treeConfig, System.IO.Path.GetFileNameWithoutExtension(text));
                EditorUtility.DisplayDialog("Export", "导出行为树配置成功:" + text, "ok");
            }
        }