- Home /
Create loading bar then scene transition
Hi... I was able to create loading bar then load next scene using SceneManager.LoadSceneAsync. However, I want instead of loading the next scene directly to create a transition effect like sliding up the loading scene and showing the next scene. Not sure if I can have the loading bar in the scene itself, then I could use Animation to create the sliding effect. but in this case I could not use SceneManager.LoadSceneAsync to create the loading bar itself as it would be a single scene in this case.. Hope it is not so confusing :-) ... I would appreciate your thoughts on how I could implement this!
For the progress bar part... Following code is used:
using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using System;
public class LevelLoader : MonoBehaviour
{
public GameObject loadingScreen;
public Slider slider;
public Text ProgressText;
public string sceneToLoad = "HomePage";
void Start ()
{
StartCoroutine(LoadAsycmchrously(sceneToLoad));
}
IEnumerator LoadAsycmchrously (string sceneToLoad)
{
AsyncOperation operation = SceneManager.LoadSceneAsync(sceneToLoad);
loadingScreen.SetActive(true);
while (operation.isDone == false)
{
float progress = Mathf.Clamp01(operation.progress / .9f);
slider.value = progress;
ProgressText.text = ((int)(progress * 100f)) + "%";
yield return null;
}
}
}
Answer by I_Am_Err00r · Aug 06, 2019 at 02:58 PM
I didn't look at your code, but just check out this video, Brackey's makes solid tutorials on the most common Unity code and design based questions, whatever tips I would give you would come from this video, and I would encourage you to subscribe to him if your new to game development because he has probably hundreds of videos all with a great explanation of code and community behind him to keep older videos up to date.
Your answer
Follow this Question
Related Questions
RPG Battle Transition 2 Answers
Loading scene with LoadSceneAsync freezes and progress jumps from 0% to 90% 2 Answers
Can you create transitions between levels using Application.LoadLevel? 6 Answers
Custom 'wipe' Transition between scenes 1 Answer
Subscribing to Unity Events with different signatures 1 Answer