示例#1
0
 public void Register(IDataPersister data)
 {
     _dataList.Add(data);
     if (_dataMap.ContainsKey(data.Key))
     {
         data.LoadData(_dataMap[data.Key]);
     }
 }
示例#2
0
        /// <summary>
        /// Load data of single persister
        /// </summary>
        /// <param name="persister"></param>
        private void LoadData(IDataPersister persister)
        {
            DataSettings dataSettings = persister.GetDataSettings();

            if (dataSettings.type == DataSettings.PersistenceType.WriteOnly || dataSettings.type == DataSettings.PersistenceType.DoNotPersist)
            {
                return;
            }

            if (Store.ContainsKey(dataSettings.dataId))
            {
                persister.LoadData(Store[dataSettings.dataId]);
            }
        }
        public static void LoadData(Scene scene)
        {
            IDataPersister[] persisters = GetDataPersisters(scene);

            SceneData sceneData = SceneDataRepository.GetSceneData(scene);

            foreach (var data in sceneData.SavedData)
            {
                IDataPersister persister = persisters.FirstOrDefault(p => Equals(data.Key, p.GetDataSettings().dataKey));
                if (persister == null)
                {
                    continue;
                }

                persister.LoadData(data.Value.Data);
            }
        }