Forum rules - please read before posting.

Problem with creating a loading bar between scenes

Hello,

I'm following this tutorial: https://adventurecreator.org/tutorials/creating-loading-bar

It seems really easy to follow and i did everything necessary, but simply the loading bar is not working.
The Loading Text is showing, so the menu is working.
I tried to click "Invert Value" in the progress bar properties and then the bar appeared but it was idle in the full loading, so it means the texture is working.

I don't really know... maybe the tutorial is too old?
AC Version: 1.72.4
Unity Version: 2020.1.13

My menu:
https://imgur.com/a/mdB8BwO

Thank you in advance

Comments

  • Both your menu and the tutorial are fine.

    The loading progress is determined by reading Unity's own AsyncOperation.progress value.

    Exactly how this value is set is down to Unity, but it's not always as clear-cut as simple as a linear progression. It's based on what needs loading, how it gets loaded, etc. It's an internal Unity process though.

    For this reason, the "Value smoothing" slider is there to help give a little bit more feeling to the loading progress - but otherwise there's not much to be done on the AC side of things.

  • Ok, got it.

    I was trying to think some workarounds, for example creating an animated image "Loading..." with the three dots animating and showing it without the progress bar.

    I decided to use the "Use loading screen" and I created a new scene with just the animated image in the middle.
    Then I put the name of the scene in the "Loading Scene Name", but there are problems:
    1) Nothing is displaying while loading
    2) A random menu appear in the following scene, even if nothing activate it ( really strange )

    I tried to write on the name field, another name of random scene, and now it appear but this scene is still, not animated. There should be some rain on the scene, but everything is still if used as a loading scene.

    So maybe the "loading scene" should be just an image (?)

  • I tried even to use another menu, with "Unity UI Prefab" as Source.

    I put that animated image in the canvas and linked the canvas to the menu, but still not working:

    https://imgur.com/a/vy712YH

    I know that it sound confusing a lot, but I just need something to let the user understand the the game is just loading (some times it takes a lot)

  • If you're looking to have a UI in only this scene, with no user control, there's no need to hook it up to AC's Menu Manager - simply being in the scene file will be enough.

    How this scene plays while loading, though, is again up to Unity. Try changing the Animator's "Update Mode" setting, to see if it can be made to animate during this time.

    On the topic of long loading times, though, there are a number of things you can do to reduce times. Outside of the typical optimisations that can be made with any Unity project, some AC-specific tweaks are covered in the Manual's "Performance and optimisation" chapter.

    Also worth mentioning is that the next major AC update will have a particular focus on performance, with an aim to improve load and startup times. Naturally the results will vary between projects, but there are some optimisations that can be made that should benefit most.

  • I'm following this tutorial: https://adventurecreator.org/tutorials/creating-loading-bar. The Menu with Loading... appears between scenes as it should, but the progress bar does not appear at all. What am I missing? I got asynchronous scene loading enabled and that is working. I am using unity 2020.2.6 Perhaps the AsyncOperation.progress value logic no longer works as before?

  • Unfortunately, Unity's AsyncOperation.progress is not always totally accurate even in the best of times.

    The AC Timer element's Value smoothing property can be used to make things feel a little nicer, as it animates the bar instead, but otherwise it's really down to the AsyncOperation itself.

    How long does your scene loading take? If it's long enough to warrant a loading screen, I'd recommend going through the Manual's "Performance and optimisation" chapter to see if any of the tips described there can be applied to your game. These are only AC-specific, however, so you should also refer to Unity's own documenation about optimising assets for improved load times.

  • My start scene takes about 6 seconds. It is Gaia Pro environment, so not much I can do about it. I will experiment with the loading scene instead. Thanks. That said the menu loading method does work between shorter scenes but the progress white bar still never shows not fills/moves.

  • I ended up using a custom script to show the loader bar like this.
    using System.Collections;
    using UnityEngine;
    using UnityEngine.SceneManagement;
    using UnityEngine.UI;

    public class LevelLoader : MonoBehaviour
    {
    public GameObject loadingScreen;
    public Slider slider;
    public Text progressText;

    public void LoadLevel(int sceneIndex)
    {
        StartCoroutine(LoadAsynchronously(sceneIndex));
    
    }
    
    IEnumerator LoadAsynchronously (int sceneIndex)
    {
        AsyncOperation operation = SceneManager.LoadSceneAsync(sceneIndex);
    
        loadingScreen.SetActive(true);
    
        while (!operation.isDone)
        {
            float progress = Mathf.Clamp01(operation.progress / .9f);
    
            slider.value = progress; //+ 0.1f;
            progressText.text = progress * 100f + "%";
            //Debug.Log(progress);
            yield return null;
        }
    }
    

    }

  • It is based on Brackey's method here:

  • That's pretty much the same code that AC uses, the behaviour should be the same.

  • edited March 2021

    I added a small enhancement to round it.

    IEnumerator LoadAsynchronously (int sceneIndex)
    {
    AsyncOperation operation = SceneManager.LoadSceneAsync(sceneIndex);

        loadingScreen.SetActive(true);
    
        while (!operation.isDone)
        {
            float progress = Mathf.Clamp01(operation.progress / .9f);
            progress = Mathf.Round(operation.progress * 100) / 100;
    
    
            slider.value = progress; //+ 0.1f;
            progressText.text = progress * 100f + "%";
            //Debug.Log(progress);
            yield return null;
        }
    }
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.