Exemplo n.º 1
0
        //Save
        protected override void OnSaved(BinaryWriter w)
        {
            base.OnSaved(w);

            bool running = _running;//_tempNodeList != null;

            //if (running) running = _tempNodeList.Length > 0;

            w.Write(running);
            if (running)
            {
                //Save Oringin Node
                //处于正在运行节点,保存初始节点及当前运行节点ID
                w.Write(_tempNodeList.Length);
                for (int i = 0; i < _tempNodeList.Length; i++)
                {
                    NodeModifier node = _tempNodeList[i];
                    System.Type  type = node.GetType();

                    w.Write(type.FullName);
                    node.Serialize(w);
                }

                w.Write(_contenNodeList.Count);
                for (int i = 0; i < _contenNodeList.Count; i++)
                {
                    w.Write(_contenNodeList[i]._id);
                }
            }
            else
            {
                //未运行节点,直接保存当前节点即可
                w.Write(_contenNodeList.Count);
                for (int i = 0; i < _contenNodeList.Count; i++)
                {
                    NodeModifier node = _contenNodeList[i];
                    System.Type  type = node.GetType();

                    w.Write(type.FullName);
                    node.Serialize(w);
                }
            }
        }
Exemplo n.º 2
0
        //Save===========================================

        public virtual void Serialize(BinaryWriter w)
        {
            w.Write(UnityEngine.JsonUtility.ToJson(this));
            w.Write(_nextNodeList.Count);
            for (int i = 0; i < _nextNodeList.Count; i++)
            {
                NodeModifier node = _nextNodeList[i];
                w.Write(node._id);//(ParentToLayer(node));
                bool isSingleNode = node.Parent != this;
                w.Write(isSingleNode);
                if (!isSingleNode)
                {
                    w.Write(node.GetType().FullName);
                    node.Serialize(w);
                }
            }

            OnSaved(w);
        }