public void Show(LoadingScreenState state) { this.m_State = state; this.m_Active = true; this.UpdateSize(true); this.SetupTexture(); }
public void UpdateLoadingScreen() { if (currentLoadingScreenState == LoadingScreenState.Disappearing) { if (currentDuration > 0) { currentDuration -= Time.deltaTime; foreach (Image loadingImage in loadingImages) { Color newColor = loadingImage.color; newColor.a = opacityCurve.Evaluate(currentDuration / disappearingDuration); loadingImage.color = newColor; } } else if (currentDuration < 0) { currentDuration = 0; foreach (Image loadingImage in loadingImages) { loadingImage.color = new Color(loadingImage.color.r, loadingImage.color.g, loadingImage.color.b, 0); currentLoadingScreenState = LoadingScreenState.Hidden; } if (OnScreenFinishedTransition != null) { OnScreenFinishedTransition(); } } } else if (currentLoadingScreenState == LoadingScreenState.Appearing) { if (currentDuration > 0) { currentDuration -= Time.deltaTime; foreach (Image loadingImage in loadingImages) { Color newColor = loadingImage.color; newColor.a = opacityCurve.Evaluate(1 - (currentDuration / appearingDuration)); loadingImage.color = newColor; } } else if (currentDuration < 0) { currentDuration = 0; foreach (Image loadingImage in loadingImages) { loadingImage.color = new Color(loadingImage.color.r, loadingImage.color.g, loadingImage.color.b, 1); currentLoadingScreenState = LoadingScreenState.Shown; } if (OnScreenFinishedTransition != null) { OnScreenFinishedTransition(); } } } }
public void StartBeginLoad(OnLoadingScreenEvent actionWhenLoaded) { currentLoadingScreenState = LoadingScreenState.Disappearing; foreach (Image loadingImage in loadingImages) { loadingImage.color = new Color(loadingImage.color.r, loadingImage.color.g, loadingImage.color.b, 1); } currentDuration = disappearingDuration; OnScreenFinishedTransition = actionWhenLoaded; }
private void OnNextSceneLoaded(Scene _scene, LoadSceneMode _mode) { if (_scene.buildIndex == (int)Scenes.Game) { loadingScreenState = LoadingScreenState.Done; onGameStarted?.Invoke(true); } else { onGameStarted?.Invoke(false); } }
private IEnumerator coroutineFunction(string sceneName) { yield return(heightAnimator.In()); state = LoadingScreenState.Loading; CustomTimer minLoadingTimer = new CustomTimer(minLoadingTime); yield return(SceneManager.LoadSceneAsync(sceneName)); yield return(minLoadingTimer); state = LoadingScreenState.Ending; yield return(heightAnimator.Out()); state = LoadingScreenState.Sleeping; }
// Start is called before the first frame update void Start() { movementInstr.SetActive(true); grabInstr.SetActive(true); attackInstr.SetActive(false); loadingText.SetActive(false); playerObjInScene = Instantiate(playerPrefab); playerObjInScene.transform.position = Vector3.zero; upperSpawnPt = new Vector3(0f, 1.5f, 0f); lowerSpawnPt = new Vector3(0f, -1.5f, 0f); timer = 200; thisState = LoadingScreenState.Practice; }
public void StartEndLoad(OnLoadingScreenEvent actionWhenLoaded) { if (GameManager.gameManager != null) { GameManager.gameManager.PauseIntrfcManager.HidePauseButton(); } currentLoadingScreenState = LoadingScreenState.Appearing; foreach (Image loadingImage in loadingImages) { loadingImage.color = new Color(loadingImage.color.r, loadingImage.color.g, loadingImage.color.b, 0); } currentDuration = appearingDuration; OnScreenFinishedTransition = actionWhenLoaded; }
public CustomAsyncOperation LoadScene(string name) { if (state != LoadingScreenState.Sleeping) { return(null); } #if UNITY_EDITOR if (GameManager.devMode) { SceneManager.LoadSceneAsync(name); } else { #endif state = LoadingScreenState.Beginning; StartCoroutine(coroutineFunction(name)); #if UNITY_EDITOR } #endif return(new CustomAsyncOperation(() => state == LoadingScreenState.Sleeping, () => progress, op => {})); }
// Update is called once per frame void Update() { switch (thisState) { case LoadingScreenState.Practice: if (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0) { hasMoved = true; } if (Input.GetMouseButton(0)) { hasGrabbed = true; } if (hasMoved && hasGrabbed) { thisState = LoadingScreenState.Pause; } break; case LoadingScreenState.Pause: timer--; if (timer < 1) { thisState = LoadingScreenState.Test; movementInstr.SetActive(false); grabInstr.SetActive(false); attackInstr.SetActive(true); loadingText.SetActive(false); GameObject objref = Instantiate(enemyPrefab); objref.transform.position = (playerObjInScene.transform.position - upperSpawnPt).sqrMagnitude > (playerObjInScene.transform.position - lowerSpawnPt).sqrMagnitude ? upperSpawnPt : lowerSpawnPt; objref.layer = 0; } break; case LoadingScreenState.Test: if (GameObject.FindGameObjectWithTag("Enemy") == null) { movementInstr.SetActive(false); grabInstr.SetActive(false); attackInstr.SetActive(false); loadingText.SetActive(true); thisState = LoadingScreenState.Loading; } break; case LoadingScreenState.Loading: default: SceneManager.LoadScene("Game"); break; } if (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0) { hasMoved = true; } if (Input.GetMouseButton(0)) { hasGrabbed = true; } }
private IEnumerator LoadSceneCR(Scenes sceneToLoad) { LoadingBarInfoText.text = "Lade " + sceneToLoad + " Scene..."; loadingScreenState = LoadingScreenState.Loading; LoadingBarForeground.fillAmount = 0f; LoadingScreenCanvas.SetActive(true); for (int i = 0; i < SceneManager.sceneCount; i++) { if (SceneManager.GetSceneAt(i).buildIndex == (int)Scenes.Loading) { SceneManager.SetActiveScene(SceneManager.GetSceneAt(i)); } else if (SceneManager.GetSceneAt(i).buildIndex != (int)sceneToLoad) { SceneManager.UnloadSceneAsync(SceneManager.GetSceneAt(i).buildIndex); } } sceneLoadingOperation = SceneManager.LoadSceneAsync((int)sceneToLoad, LoadSceneMode.Additive); while (!sceneLoadingOperation.isDone || loadingScreenState != LoadingScreenState.Done) { LoadingBarForeground.fillAmount = sceneLoadingOperation.progress; switch (loadingScreenState) { case LoadingScreenState.Loading: LoadingBarInfoText.text = "Lade " + sceneToLoad + " Scene..."; break; case LoadingScreenState.Done: LoadingBarInfoText.text = "Fertig mit laden."; break; case LoadingScreenState.ConnectingTwitchAPI: LoadingBarInfoText.text = "Verbinde zur Twitch API..."; break; case LoadingScreenState.ConnectedTwitchAPI: LoadingBarInfoText.text = "Verbinde zur Twitch API hergestellt."; break; case LoadingScreenState.FailedToConnectTwitchAPI: LoadingBarInfoText.text = "Verbinde zur Twitch API konnte nicht hergestellt werden."; break; } yield return(new WaitForEndOfFrame()); } yield return(new WaitForSeconds(0.5f)); for (int i = 0; i < SceneManager.sceneCount; i++) { if (SceneManager.GetSceneAt(i).buildIndex == (int)sceneToLoad) { SceneManager.SetActiveScene(SceneManager.GetSceneAt(i)); } } LoadingScreenCanvas.SetActive(false); LoadingBarInfoText.text = ""; LoadingBarForeground.fillAmount = 0f; }
public void SetLoadingScreenState(LoadingScreenState _loadingScreenState) { loadingScreenState = _loadingScreenState; }