Beispiel #1
0
        public virtual void LoadEditor(NodeFlowEditorWindow _editor, string path)
        {
            editor = _editor;
            editor.nodeDef.Clear();
            NodeDef nodeDef = new NodeDef();

            nodeDef.MakeDefault();
            editor.nodeDef.Add(nodeDef);
            editor.connectDef.Clear();
            editor.connectDef.Add(new ConnectionDef());
            editor.globalEventDef.Clear();
            //editor.variableDef.Clear();

            XmlDocument doc = new XmlDocument();

            path = Application.dataPath + "/Editor/NodeFlow/Editor/" + path;
            doc.Load(path);
            XmlNode editorNode = doc.SelectSingleNode("editor");

            if (editorNode == null)
            {
                UnityEngine.Debug.LogError("editor config load error! " + path);
                goto __end;
            }

            editor.edtorName = (editorNode as XmlElement).GetAttribute("name");
            editor.version   = (editorNode as XmlElement).GetAttribute("version");

            if (!editorNode.HasChildNodes)
            {
                goto __end;
            }

            XmlNode cfgNode = editorNode.FirstChild;

            while (cfgNode != null)
            {
                XmlElement cfgElm     = cfgNode as XmlElement;
                string     cfgElmName = cfgElm.Name;
                if (cfgElmName.Equals("node_def"))
                {
                    ParseNodeDef(cfgElm);
                }
                else if (cfgElmName.Equals("connection_def"))
                {
                    ParseConnectDef(cfgElm);
                }
                else if (cfgElmName.Equals("event_def"))
                {
                    ParseEventDef(cfgElm);
                }
                else
                {
                    UnityEngine.Debug.LogError("can not parse element :" + cfgElmName);
                }
                cfgNode = cfgNode.NextSibling;
            }
__end:
            editor.OnEditorMetaLoaded();
        }
Beispiel #2
0
        public static EditorWindow OpenBTEdtior()
        {
            NodeFlowEditorWindow window = GetWindow(typeof(NodeFlowEditorWindow)) as NodeFlowEditorWindow;

            window.name = "行为树编辑器";

            NodeFlowEditorSerializeBase ser = new NodeFlowEditorSerializeBase();

            ser.editor       = window;
            window.serialize = ser;
            NodeFlowEditorLoader.LoadEditor(window, "BTEditor.xml");
            window.Show();

            window.OnShow();
            return(window);
        }
Beispiel #3
0
        public virtual void SaveToXml(NodeFlowEditorWindow editor, string path, NodeFlow flow)
        {
            XmlDocument doc  = new XmlDocument();
            XmlElement  root = doc.CreateElement("editor");

            doc.AppendChild(root);

            root.SetAttribute("name", editor.edtorName);
            root.SetAttribute("version", editor.version);
            SerializeFlow(root, flow);

            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Encoding = new System.Text.UTF8Encoding(false);
            settings.Indent   = true;

            XmlWriter xmlWriter = XmlWriter.Create(path, settings);

            doc.Save(xmlWriter);
            xmlWriter.Flush();
            xmlWriter.Close();
            doc       = null;
            xmlWriter = null;
        }
 void OnEnable()
 {
     instance     = this;
     this.minSize = new Vector2(windowWidth, windowHeight);
 }
Beispiel #5
0
 public static void SaveToXml(NodeFlowEditorWindow editor, string path, NodeFlow flow)
 {
     editor.serialize.SaveToXml(editor, path, flow);
 }
Beispiel #6
0
 public static void LoadEditor(NodeFlowEditorWindow editor, string path)
 {
     serialize = editor.serialize;
     serialize.LoadMeataEditor(path);
 }