Jump to content
Unity Insider Forum

LoadSceneAsync hängt


Ich

Recommended Posts

Hallo,

Wenn ich eine große Unity Scene laden will hängt Unity ca.4 Sekunden weil alles laden muss.

Ich möchte aber das mein Loading bar sich füllt (mit AsyncOperation.progress) und Unity nicht hängen bleibt.

 

    public Image img_load;

    private void Awake()
    {
        img_load.fillAmount = loadPercent;
        LoadScene(1);
    }


    public void LoadScene(int s)
    {
        StartCoroutine(LoadAsync(s));
    }


    float loadPercent;
    private void LateUpdate()
    {
        img_load.fillAmount = loadPercent;
    }


    IEnumerator LoadAsync(int s)
    {
        AsyncOperation operation = SceneManager.LoadSceneAsync(s);
        loadPercent = operation.progress;
        while (!operation.isDone)
        {
            yield return null;
        }
    }

 

Link zu diesem Kommentar
Auf anderen Seiten teilen

Du setzt "loadPercent" nur einmalig am Anfang des Ladevorgangs.

Versuch's mal damit:

    IEnumerator LoadAsync(int s)
    {
        AsyncOperation operation = SceneManager.LoadSceneAsync(s);
        while (!operation.isDone)
        {
            img_load.fillAmount = operation.progress;
            yield return null;
        }
    }

 

Link zu diesem Kommentar
Auf anderen Seiten teilen

Archiviert

Dieses Thema ist jetzt archiviert und für weitere Antworten gesperrt.

×
×
  • Neu erstellen...