public static void WirteXMLAtPath(BTEditorConfig _bTree, string _path)
        {
            XmlSerializer writer = new XmlSerializer(typeof(BTEditorConfig));
            StreamWriter  file   = new StreamWriter(_path);

            writer.Serialize(file, _bTree);
            file.Close();
        }
        public static void WriteBinary(BTEditorConfig _bTree, string _name)
        {
            FileStream      fs = new FileStream(saveConfigPath + _name + mSuffix, FileMode.OpenOrCreate);
            BinaryFormatter binaryFormatter = new BinaryFormatter();

            binaryFormatter.Serialize(fs, _bTree);
            fs.Close();
        }
        public static BTEditorConfig ReadXMLAtPath(string _path)
        {
            XmlSerializer  reader = new XmlSerializer(typeof(BTEditorConfig));
            StreamReader   file   = new StreamReader(_path);
            BTEditorConfig btree  = reader.Deserialize(file) as BTEditorConfig;

            file.Close();
            return(btree);
        }
        public static BTEditorConfig ReadBinary(string _name)
        {
            FileStream      fs = new FileStream(saveConfigPath + _name + mSuffix, FileMode.Open);
            BinaryFormatter binaryFormatter = new BinaryFormatter();
            BTEditorConfig  bTree           = binaryFormatter.Deserialize(fs) as BTEditorConfig;

            fs.Close();
            return(bTree);
        }
Example #5
0
        public void LoadBTree()
        {
            string text = EditorUtility.OpenFilePanel("Load Behavior Tree", BTEditorUtility.editorPath + "Config", "xml");

            if (!string.IsNullOrEmpty(text))
            {
                Debugger.Log("loadBTree");
                BTEditorConfig _config = BTEditorSerialization.ReadXMLAtPath(text);
                mGraphDesigner = (new BTGraphDesigner());
                mGraphDesigner.Load(_config);
            }
        }
        public static BTEditorConfig CreateBtreeEditorConfigFromGraphDesigner(BTGraphDesigner _graphDesigner)
        {
            BTEditorConfig _config = new BTEditorConfig();

            _config.mRootNode = CreateEditorTreeConfigFromRootEditorNode(_graphDesigner.mRootNode);
            _config.mRootNode.mIsEnterNode = true;

            _config.mDetachedNode = new List <BTEditorTreeConfig>();
            for (int i = 0; i < _graphDesigner.mDetachedNodes.Count; i++)
            {
                _config.mDetachedNode.Add(CreateEditorTreeConfigFromRootEditorNode(_graphDesigner.mDetachedNodes[i]));
            }
            return(_config);
        }
Example #7
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);
         }
     }
 }
Example #8
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");
            }
        }
 public static void WriteXML(BTEditorConfig _bTree, string _name)
 {
     WirteXMLAtPath(_bTree, saveConfigPath + _name + ".xml");
 }