public void Load(Action <Scene> callback) { if (dontLoadDuplicate && Scenes.IsActiveOrBeingLoaded(sceneInfo)) { return; } Action <Scene> localCallback = (scene) => { if (callback != null) { callback(scene); } if (onLoadComplete != null) { onLoadComplete.Invoke(scene); } }; if (loadAsync) { Scenes.LoadAsync(sceneInfo, localCallback); } else { Scenes.Load(sceneInfo, localCallback); } }
void SceneLoaded(Scene scene, LoadSceneMode mode) { if (isFirstLoad) { isFirstLoad = false; } else { if (destroyOnScenesWithoutIt && !duplicateDestroyed) { SelfDestruct(); } else { sceneLoaded?.Invoke(scene); if (scene.buildIndex != currentScene) { sceneChanged?.Invoke(scene); currentScene = scene.buildIndex; } else { sceneRestarted?.Invoke(); } } } }
private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (_event != ScriptEvent.SceneLoaded) { return; } _onSceneLoaded.Invoke(scene); }
void setState(SceneState newState) { if (state == newState) { return; } state = newState; Debug.Log("[Scene] State change " + state); sceneStateChanged?.Invoke(this); }
IEnumerator LoadSceneCo(string sceneName) { loadingInProgress = true; yield return(new WaitForSeconds(2f)); for (int i = 0; i < SceneManager.sceneCount; i++) { var scene = SceneManager.GetSceneAt(i); if (scene.name.Contains("Level")) { yield return(UnloadSceneCo(scene)); } else if (scene.name.Contains("Test")) { sceneName = "Test"; } } OnSceneStartedLoading.Invoke(); yield return(SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive)); var loadedScene = SceneManager.GetSceneByName(sceneName); if (loadedScene.name.Contains("Level") || loadedScene.name.Contains("Test")) { SceneManager.SetActiveScene(loadedScene); yield return(new WaitForSeconds(0.2f)); OnSceneLoaded.Invoke(); } OnSceneInfo.Invoke(loadedScene, true); loadingInProgress = false; }
public void Load(int index, LoadSceneMode mode) { var request = SceneManager.LoadSceneAsync(index, mode); if (!_allowSceneActivation) { _currentRequest = request; } request.priority = _priority; request.allowSceneActivation = _allowSceneActivation; request.completed += op => { _onLoadedScene.Invoke(SceneManager.GetSceneByBuildIndex(index)); _onLoadedSceneIndex.Invoke(index); }; StartCoroutine(ProgressRoutine(request)); }
public void LoadScene(States.State name) { RKLog.Log("load scene " + name, "sceneloader"); if (scenes[name].loading == false && scenes[name].loaded == false) { // Debug.LogError(scenes[name].name); scenes[name].loading = true; GameObject g = HelperFunctions.GetPrefab2d(scenes[name].name, scenes[name].target); if (g == null) { Debug.LogError("NO GAMEOBJECT LOADED " + name); return; } SceneBaseClass sb = g.GetComponent <SceneBaseClass>(); if (sb == null) { Debug.LogError("NO SCENEBASECLASS LOADED " + name); return; } scenes[name].gameobject = g; scenes[name].Scene = sb; scenes[name].loaded = true; scenes[name].load = false; scenes[name].loading = false; bool issceneloaded = false; sceneloaded.Invoke(name); CheckLoadedAll(); } else if (scenes[name].loaded) { Debug.LogError("Scene " + name + " already loaded"); } }
void OnSceneLoaded(ISceneLoadPromise sceneLoadPromise) { onLoadComplete?.Invoke(sceneLoadPromise.Scene); }
public void CloseGo() { SceneCloseEvent?.Invoke(); }
public void OpenGo() { SceneOpenEvent?.Invoke(); }
public void LoadingOpenGo() { sceneOpenEvent?.Invoke(); }
public void LoadingCloseGo() { sceneCloseEvent?.Invoke(); }
/// <summary> /// Updates all the game objects in this scene. /// </summary> /// <param name="gameTime"></param> public virtual void Update(GameTime gameTime) { for (int i = 0; i < repeatFunctions.Count; i++) { FunctionCall c = repeatFunctions[i]; c.Timer -= Time.Instance.DeltaTime; if (c.Timer <= 0) { c.Action.Invoke(); if (c.isRepeating) { c.Timer = c.Interval; } else { repeatFunctions.RemoveAt(i--); } } } // updates the objects foreach (GameObject obj in objects.Values) { if (obj.IsActive) { obj.Update(gameTime); if (uiState == UIState.Gameplay || uiState == UIState.Parallel || uiState == UIState.Closed) { obj.ProcessInput(InputManager.Instance); } } } // adds the queued objects while (addObjects.Count > 0) { GameObject obj = addObjects.Dequeue(); do { obj.GenerateNewID(); } while (objects.ContainsKey(obj.ID)); objects.Add(obj.ID, obj); obj.OnDestroy += OnObjectDestruction; obj.Load(initializer); OnObjectAdded?.Invoke(obj); } // removes the queued objects while (removeObjects.Count > 0) { GameObject obj = removeObjects.Dequeue(); RemoveObject(obj.ID); obj.OnDestroy -= OnObjectDestruction; } foreach (UIScreen ui in uiStack) { ui.Update(gameTime); } if (uiState != UIState.Closed && uiStack.Count != 0) { ProcessInputUI(); } }