Пример #1
0
        /// <summary>
        /// Unity Method
        /// </summary>
        private void Awake()
        {
            ReplayEntity data = new ReplayEntity();

            this.DataEntity = data;
            Watch(this);
        }
Пример #2
0
        /// <summary>
        /// 场景还原前,预制体准备操作
        /// </summary>
        public override void LoadStorageData()
        {
            ReplayEntity data = (ReplayEntity)DataEntity;

            //多次点击 还原
            if (data.sceneIdNameOfPrefab.Count == _sceneIdNameOfPrefab.Count)
            {
                return;
            }
            _sceneIdNameOfPrefab.Clear();

            data.sceneIdNameOfPrefab.ForEach(p => _sceneIdNameOfPrefab.Add(p));


            string sceneName = SceneManager.GetActiveScene().name;

            //生成所有的预制体
            for (int i = 0; i < data.sceneIdNameOfPrefab.Count; i++)
            {
                //生成属于当前场景的预制体
                if (data.sceneIdNameOfPrefab[i].Split('=')[0].Equals(sceneName))
                {
                    string     name = data.sceneIdNameOfPrefab[i].Split('=')[2];
                    GameObject go   = GetInstance(name, Vector3.zero);
                    RegisterPrefab(go);

                    DataModelBehaviour dataModel = go.GetComponent <DataModelBehaviour>();
                    if (dataModel != null)
                    {
                        RestoreSystem.AddDataModel(dataModel.DataEntity.objectID, dataModel);
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        /// 保存
        /// </summary>
        public override void SaveStorageData()
        {
            //先写入预制体数据
            ReplayEntity data = (ReplayEntity)this.DataEntity;

            data.sceneIdNameOfPrefab.Clear();
            _sceneIdNameOfPrefab.ForEach(p => data.sceneIdNameOfPrefab.Add(p));
            //保存场景信息
            data.sceneName = SceneManager.GetActiveScene().name;
        }
        /// <summary>
        /// 场景恢复
        /// </summary>
        public void RestoreScene()
        {
            //先处理场景问题,还原场景管理DataModel的entity
            ReplayManager replayLoader = GetComponent <ReplayManager>();

            _restoreSystem.Load(replayLoader.DataEntity);

            //判断是否是当前场景
            ReplayEntity sceneEntity = (ReplayEntity)replayLoader.DataEntity;

            //加载场景
            StartCoroutine(LoadScene(sceneEntity.sceneName));
        }