Page 2 of 3

Re: Custom loading bar

Posted: Wed Dec 01, 2021 2:13 pm
by Tony Li
Sorry, add .ToString() to the end of the line. See my edit above in my previous post.

Re: Custom loading bar

Posted: Wed Dec 01, 2021 3:09 pm
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

Re: Custom loading bar

Posted: Wed Dec 01, 2021 3:31 pm
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.

Re: Custom loading bar

Posted: Wed Dec 01, 2021 5:04 pm
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..


Re: Custom loading bar

Posted: Wed Dec 01, 2021 5:21 pm
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;
        }
    }
}

Re: Custom loading bar

Posted: Wed Dec 01, 2021 5:51 pm
by hrohibil
This is what i get..



Line 25 is:

Code: Select all

progressText.text = Mathf.Clamp(SaveSystem.currentAsyncOperation.progress * 100f, 0f, 100f).ToString();

Re: Custom loading bar

Posted: Wed Dec 01, 2021 6:23 pm
by hrohibil
I received an notification that a new post from you but I don’t see it??

Re: Custom loading bar

Posted: Wed Dec 01, 2021 7:50 pm
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.

Re: Custom loading bar

Posted: Wed Dec 01, 2021 8:03 pm
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

Re: Custom loading bar

Posted: Thu Dec 02, 2021 2:32 am
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