コード例 #1
0
        public void saveBTree(string type)
        {
            if (mGraphDesigner == null || mGraphDesigner.m_RootNode == null)
            {
                EditorUtility.DisplayDialog("Save Error", "未创建根节点", "ok");
                return;
            }
            string suffix = "";

            if (type == "xml")
            {
                suffix = "xml";
            }
            else if (type == "binary")
            {
                suffix = "btreeEditor";
            }
            string text = EditorUtility.SaveFilePanel("Save Behavior Tree", BTreeEditorSerialization.m_ConfigPath, mGraphDesigner.m_RootNode.m_NodeName, suffix);

            if (text.Length != 0 && Application.dataPath.Length < text.Length)
            {
                Debugger.Log("saveBTree");
                BTreeEditorConfig _config = BTreeEditorNodeFactory.CreateBtreeEditorConfigFromGraphDesigner(mGraphDesigner);
                BTreeEditorSerialization.WirteXMLAtPath(_config, text);
                EditorUtility.DisplayDialog("Save", "保存行为树编辑器成功:" + text, "ok");
            }
        }
コード例 #2
0
 //加载
 public void load(BTreeEditorConfig _config)
 {
     m_RootNode = BTreeEditorNodeFactory.CreateBTreeNodeDesignerFromConfig(_config.m_RootNode)[0];
     m_RootNode.SetEntryDisplay(true);
     if (_config.m_DetachedNode != null)
     {
         m_DetachedNodes = new List <BTreeNodeDesigner>();
         for (int i = 0; i < _config.m_DetachedNode.Count; i++)
         {
             BTreeNodeDesigner _detachedNode = BTreeEditorNodeFactory.CreateBTreeNodeDesignerFromConfig(_config.m_DetachedNode[i])[0];
             m_DetachedNodes.Add(_detachedNode);
         }
     }
 }
コード例 #3
0
        public void exportBtree()
        {
            if (mGraphDesigner == null || mGraphDesigner.m_RootNode == null)
            {
                EditorUtility.DisplayDialog("Export Error", "未创建根节点", "ok");
                return;
            }
            Debugger.Log("exportBtree");
            TreeConfig _treeConfig = BTreeEditorNodeFactory.CreateTreeConfigFromBTreeGraphDesigner(mGraphDesigner);
            string     name        = mGraphDesigner.m_RootNode.m_NodeName;

            BTreeNodeSerialization.WriteBinary(_treeConfig, name);
            EditorUtility.DisplayDialog("Export", "导出行为树配置成功:" + name, "ok");
        }