Beispiel #1
0
 protected override void OnCreate()
 {
     base.OnCreate();
     InitializeReadWrite(PersistencySettings.Get());
     _applyRequests = new List <PersistentDataContainer>(8);
     _ecbSystem     = World.GetOrCreateSystem <EndInitializationEntityCommandBufferSystem>();
     _initialStatePersistRequests = new List <PersistentDataContainer>(8);
 }
        public static PersistencySettings Get()
        {
#if UNITY_EDITOR
            PersistencySettings settings = UnityEditor.AssetDatabase.LoadAssetAtPath <PersistencySettings>(AssetPath);
#else
            // This only actually loads it the first time, so multiple calls are totally fine
            PersistencySettings settings = Resources.Load <PersistencySettings>(RelativeFilePathNoExt);
#endif
            return(settings);
        }
        protected void InitializeReadWrite(PersistencySettings settings)
        {
            PersistencySettings = settings;
            if (PersistencySettings == null)
            {
                Enabled = false;
                return;
            }

            PersistableEntitiesQuery = CreateEntityQuery();
        }
Beispiel #4
0
        protected override void OnCreate()
        {
            PersistencySettings = PersistencySettings.Get();
            if (PersistencySettings == null)
            {
                Enabled = false;
                Debug.Log(PersistencySettings.NotFoundMessage);
            }
            PersistentDataStorage = new PersistentDataStorage(1);

            _beginFrameSystem = World.GetOrCreateSystem <BeginFramePersistencySystem>();
            _ecbSystem        = World.GetOrCreateSystem <EndInitializationEntityCommandBufferSystem>();

            _scenePersistencyInfoQuery      = GetEntityQuery(ComponentType.ReadOnly <ScenePersistencyInfoRef>(), ComponentType.ReadOnly <PersistencyContainerTag>());
            _sceneSectionLoadedCheckQuery   = GetEntityQuery(ComponentType.ReadOnly <SceneSection>());
            _resizeContainerDependencyQuery = GetEntityQuery(ComponentType.ReadOnly <PersistenceState>());
            RequireForUpdate(GetEntityQuery(ComponentType.ReadOnly <RequestPersistentSceneSectionLoaded>(), ComponentType.ReadOnly <SceneSectionData>(), ComponentType.Exclude <PersistentSceneSectionLoadComplete>()));
        }
        protected override void OnCreate()
        {
            base.OnCreate();

            InitializeReadOnly(PersistencySettings.Get());
            _ecbSystem       = World.GetOrCreateSystem <BeginInitializationEntityCommandBufferSystem>();
            _containerSystem = World.GetOrCreateSystem <PersistentSceneSystem>();

            _autoPersistRequests = GetEntityQuery(ComponentType.ReadOnly <SceneSectionData>(),
                                                  ComponentType.ReadOnly <RequestSceneLoaded>(),
                                                  ComponentType.ReadOnly <PersistentSceneSectionLoadComplete>(),
                                                  ComponentType.Exclude <RequestPersistentSceneSectionLoaded>(),
                                                  ComponentType.Exclude <DisableAutoPersistOnUnload>());

            _unloadRequests = GetEntityQuery(ComponentType.ReadOnly <SceneSectionData>(),
                                             ComponentType.ReadOnly <RequestSceneLoaded>(),
                                             ComponentType.ReadOnly <PersistentSceneSection>(),
                                             ComponentType.Exclude <RequestPersistentSceneSectionLoaded>());

            _persistRequests = new List <PersistentDataContainer>(8);
        }