Beispiel #1
0
        /// <summary>
        /// 还原数据
        /// </summary>
        /// <param name="overlord"></param>
        /// <returns>数据结构是否改变</returns>
        public bool RestoreData(GKToyBaseOverlord overlord)
        {
            _overlord = overlord;
            LoadVariable(overlord, this);
            nodeLst.Clear();
            int  i           = 0;
            bool isEditor    = GKEditor.isUnityEditor();
            bool dataChanged = false;

            foreach (var d in nodeData)
            {
                Type t = GKToyMakerTypeManager.Instance().typeAssemblyDict[nodeTypeData[i]].GetType(nodeTypeData[i]);
                var  n = (GKToyNode)JsonUtility.FromJson(d, t);
                if (n.Restore(d) && !dataChanged)
                {
                    dataChanged = true;
                }
                if (isEditor && typeof(GKToyNodeGroup) == t)
                {
                    ((GKToyNodeGroup)n).data = this;
                }
                nodeLst.Add(n.id, n);
                i++;
            }
            return(dataChanged);
        }
Beispiel #2
0
 static public GKToyMakerTypeManager Instance()
 {
     if (_instance == null)
     {
         _instance = new GKToyMakerTypeManager();
     }
     return(_instance);
 }
Beispiel #3
0
        // Json转化为节点.
        public void LoadNodes()
        {
            nodeLst.Clear();
            int  i        = 0;
            bool isEditor = GKEditor.isUnityEditor();

            foreach (var d in nodeData)
            {
                Type t = GKToyMakerTypeManager.Instance().typeAssemblyDict[nodeTypeData[i]].GetType(nodeTypeData[i]);
                var  n = (GKToyNode)JsonUtility.FromJson(d, t);
                n.Init(_overlord);
                if (isEditor && typeof(GKToyNodeGroup) == t)
                {
                    ((GKToyNodeGroup)n).data = this;
                }
                nodeLst.Add(n.id, n);
                i++;
            }
        }