private void UpdateLoadingConfig() { // Tick this world specifically to ensure our load requests are handled m_SceneStreamingSystem.Update(); var configStatus = SceneService.GetSceneStatus(m_World, m_ConfigScene); if (configStatus == SceneStatus.Loaded) { if (m_Environment.configEntity == Entity.Null) { using (var configurationQuery = m_EntityManager.CreateEntityQuery(typeof(ConfigurationTag))) { if (configurationQuery.CalculateEntityCount() == 0) { throw new Exception($"Failed to load boot configuration scene."); } using (var configEntityList = configurationQuery.ToEntityArray(Allocator.Temp)) { // Set new config entity if (configEntityList.Length > 1) { throw new Exception( $"More than one configuration entity found in boot configuration scene."); } m_Environment.configEntity = configEntityList[0]; } } } } else if (configStatus == SceneStatus.FailedToLoad) { throw new Exception($"Failed to load the boot configuration scene."); } else { return; } LoadStartupScenes(m_Environment); m_BootPhase = BootPhase.Running; }
protected override void OnUpdate() { bool isGenerate = false; Entities.ForEach(( ref FirstSetInfo info ) => { if (!info.Initialized) { info.Initialized = true; isGenerate = true; } }); //Entity blkEntity = Entity.Null; if (isGenerate) { // 初期配置ブロック生成. var env = World.TinyEnvironment(); for (int i = 0; i < FirstBlockNum; ++i) { SceneService.LoadSceneAsync(env.GetConfigData <GameConfig>().PrefabBlockStay); } } #if false if (blkEntity != Entity.Null) { Debug.LogAlways("--------------"); SceneStatus st = SceneService.GetSceneStatus(blkEntity); switch (st) { case SceneStatus.Loading: Debug.LogAlways("loading"); break; case SceneStatus.Loaded: Debug.LogAlways("loaded"); break; } Debug.LogFormatAlways("{0}", (int)st); } #endif }
/// <summary> /// Checks if a certain scene is loaded /// </summary> /// <param name="scene">A reference to the scene to check</param> /// <returns>A bool equal to if the scene is loaded or not</returns> public static bool IsSceneLoaded(Entity scene) { return(SceneService.GetSceneStatus(scene) == SceneStatus.Loaded); }
private static bool MainLoop() { if (m_BootPhase == BootPhase.Running) { m_World.Update(); } else if (m_BootPhase == BootPhase.Booting) { var em = m_World.EntityManager; // Destroy current config entity if (em.Exists(m_Environment.configEntity)) { em.DestroyEntity(m_Environment.configEntity); m_Environment.configEntity = Entity.Null; } m_ConfigScene = SceneService.LoadConfigAsync(); m_BootPhase = BootPhase.LoadingConfig; } else if (m_BootPhase == BootPhase.LoadingConfig) { var em = m_World.EntityManager; var sceneStreamingSystem = m_World.GetOrCreateSystem <SceneStreamingSystem>(); // Tick this world specifically to ensure our request is handled sceneStreamingSystem.Update(); var sceneStatus = SceneService.GetSceneStatus(m_ConfigScene); if (sceneStatus == SceneStatus.Loaded) { using (var configurationQuery = em.CreateEntityQuery(typeof(ConfigurationTag))) { if (configurationQuery.CalculateLength() == 0) { throw new Exception($"Failed to load boot configuration scene."); } using (var configEntityList = configurationQuery.ToEntityArray(Allocator.Temp)) { // Set new config entity if (configEntityList.Length > 1) { throw new Exception($"More than one configuration entity found in boot configuration scene."); } m_Environment.configEntity = configEntityList[0]; } } LoadStartupScenes(); m_BootPhase = BootPhase.Running; } else if (sceneStatus == SceneStatus.FailedToLoad) { throw new Exception($"Failed to load the boot configuration scene."); } } else { throw new Exception("Invalid BootPhase specified"); } return(!m_World.QuitUpdate); }