示例#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 static void WirteXMLAtPath(BTreeEditorConfig _bTree, string _path)
        {
            XmlSerializer writer = new XmlSerializer(typeof(BTreeEditorConfig));

            System.IO.StreamWriter file = new System.IO.StreamWriter(_path);
            writer.Serialize(file, _bTree);
            file.Close();
        }
示例#3
0
        public static void WriteBinary(BTreeEditorConfig _bTree, string _name)
        {
            System.IO.FileStream fs = new System.IO.FileStream(m_ConfigPath + _name + m_Suffix, System.IO.FileMode.OpenOrCreate);
            BinaryFormatter      binaryFormatter = new BinaryFormatter();

            binaryFormatter.Serialize(fs, _bTree);
            fs.Close();
        }
示例#4
0
        public static BTreeEditorConfig ReadBinary(string _name)
        {
            System.IO.FileStream fs = new System.IO.FileStream(m_ConfigPath + _name + m_Suffix, System.IO.FileMode.Open);
            BinaryFormatter      binaryFormatter = new BinaryFormatter();
            BTreeEditorConfig    bTree           = binaryFormatter.Deserialize(fs) as BTreeEditorConfig;

            fs.Close();
            return(bTree);
        }
示例#5
0
        public static BTreeEditorConfig ReadXMLAtPath(string _path)
        {
            XmlSerializer reader = new XmlSerializer(typeof(BTreeEditorConfig));

            System.IO.StreamReader file  = new System.IO.StreamReader(_path);
            BTreeEditorConfig      btree = reader.Deserialize(file) as BTreeEditorConfig;

            file.Close();
            return(btree);
        }
        public void loadBTree()
        {
            string text = EditorUtility.OpenFilePanel("Load Behavior Tree", "Assets/Editor/BtreeEditor/Config", "xml");

            if (!string.IsNullOrEmpty(text))
            {
                Debugger.Log("loadBTree");
                BTreeEditorConfig _config = BTreeEditorSerialization.ReadXMLAtPath(text);
                mGraphDesigner = (new BTreeGraphDesigner());
                mGraphDesigner.load(_config);
            }
        }
        public static BTreeEditorConfig CreateBtreeEditorConfigFromGraphDesigner(BTreeGraphDesigner _graphDesigner)
        {
            BTreeEditorConfig _config = new BTreeEditorConfig();

            _config.m_RootNode = CreateEditorTreeConfigFromRootEditorNode(_graphDesigner.m_RootNode);
            _config.m_RootNode.m_IsEnterNode = true;

            _config.m_DetachedNode = new List <BTreeEditorTreeConfig>();
            for (int i = 0; i < _graphDesigner.m_DetachedNodes.Count; i++)
            {
                _config.m_DetachedNode.Add(CreateEditorTreeConfigFromRootEditorNode(_graphDesigner.m_DetachedNodes[i]));
            }
            return(_config);
        }
 //加载
 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);
         }
     }
 }
示例#9
0
        public void loadBTree(string type)
        {
            string text = EditorUtility.OpenFilePanel("Load Behavior Tree", BTreeEditorSerialization.m_ConfigPath, type);

            if (!string.IsNullOrEmpty(text))
            {
                Debugger.Log("loadBTree:" + type);
                BTreeEditorConfig _config = null;
                if (type == "xml")
                {
                    _config = BTreeEditorSerialization.ReadXMLAtPath(text);
                }
                else if (type == "binary")
                {
                    _config = BTreeEditorSerialization.ReadBinary(text);
                }
                mGraphDesigner = (new BTreeGraphDesigner());
                mGraphDesigner.load(_config);
            }
        }
示例#10
0
 public static void WriteXML(BTreeEditorConfig _bTree, string _name)
 {
     WirteXMLAtPath(_bTree, m_ConfigPath + _name + ".xml");
 }