Custom loading bar

Announcements, support questions, and discussion for the Dialogue System.
User avatar
Tony Li
Posts: 21079
Joined: Thu Jul 18, 2013 1:27 pm

Re: Custom loading bar

Post by Tony Li »

Sorry, add .ToString() to the end of the line. See my edit above in my previous post.
hrohibil
Posts: 358
Joined: Thu Nov 04, 2021 12:50 pm

Re: Custom loading bar

Post by hrohibil »

Sorry man..
I edited my post before yours , hoping that you would read the edit/update..

I did that already, and that did clear the error. But the value just stays at 0% while the bar moves correctly..

I out that script on the UI created text gameobject
User avatar
Tony Li
Posts: 21079
Joined: Thu Jul 18, 2013 1:27 pm

Re: Custom loading bar

Post by Tony Li »

As a test, try setting the line to this:

Code: Select all

progressText.text = SaveSystem.currentAsyncOperation.progress.ToString();
It should show the progress number in the range 0.0 to 1.0. If that works, then please post your copy of the previous script with the Mathf.Clamp part.
hrohibil
Posts: 358
Joined: Thu Nov 04, 2021 12:50 pm

Re: Custom loading bar

Post by hrohibil »

Thank you for spending time on this one Toni.. I really appreciate it..

I thought it was easier to just show you a video..

User avatar
Tony Li
Posts: 21079
Joined: Thu Jul 18, 2013 1:27 pm

Re: Custom loading bar

Post by Tony Li »

Hmm, that looks like it should work. Are there any errors or warnings in the Console window?

Try adding some debug lines:

Code: Select all

using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class LoadingProgressText : MonoBehaviour
{
    IEnumerator Start()
    {
        var progressText = GetComponent<UnityEngine.UI.Text>();
        while (true)
        {
            if (progressText == null) 
            {
                Debug.Log("No Text element");
            }
            else if (SaveSystem.currentAsyncOperation == null)
            {
                Debug.Log("SaveSystem.currentAsyncOperation is null");
            }
            else
            {
                progressText.text = Mathf.Clamp(SaveSystem.currentAsyncOperation.progress * 100f, 0f, 100f).ToString();
            }
            yield return null;
        }
    }
}
hrohibil
Posts: 358
Joined: Thu Nov 04, 2021 12:50 pm

Re: Custom loading bar

Post by hrohibil »

This is what i get..



Line 25 is:

Code: Select all

progressText.text = Mathf.Clamp(SaveSystem.currentAsyncOperation.progress * 100f, 0f, 100f).ToString();
hrohibil
Posts: 358
Joined: Thu Nov 04, 2021 12:50 pm

Re: Custom loading bar

Post by hrohibil »

I received an notification that a new post from you but I don’t see it??
User avatar
Tony Li
Posts: 21079
Joined: Thu Jul 18, 2013 1:27 pm

Re: Custom loading bar

Post by Tony Li »

The script did not paste properly into my previous post. Please try the script again, using the edits I made to it.
User avatar
Tony Li
Posts: 21079
Joined: Thu Jul 18, 2013 1:27 pm

Re: Custom loading bar

Post by Tony Li »

If you just want a copy that works, instead of learning the scripts for now, here's a working loading screen with slider and percent text:

DS_InvectorLoadingScreenWithProgress_2021-12-01.unitypackage
hrohibil
Posts: 358
Joined: Thu Nov 04, 2021 12:50 pm

Re: Custom loading bar

Post by hrohibil »

So i just add this new loadingscreen to the build.
And is it only in the SAVE SYSTEM prefab in the loading sreen name i change the name to the new name?
Or is there more places?

Because i am getting below error

Post Reply