[SOLVED]My UI text don't update from script

I have the following script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class SceneFader : MonoBehaviour {

    public Image img;
    public AnimationCurve curve;
    private float _progress = 0f;
    public Text loadingText;

    private void Start()
    {
        StartCoroutine(FadeIn());
    }

    public void FadeTo(string scene)
    {
        StartCoroutine(FadeOut(scene));
    }

    IEnumerator FadeIn()
    {
        float t = 1f;

        while(t > 0f)
        {
            t -= Time.deltaTime;
            float a = curve.Evaluate(t);
            img.color = new Color(0f, 0f, 0f, a);
            yield return 0;
        }
    }

    IEnumerator FadeOut(string scene)
    {
        AsyncOperation operation = SceneManager.LoadSceneAsync(scene);

        operation.allowSceneActivation = false;

        while(_progress < 1f)
        {
            _progress = Mathf.Clamp01(operation.progress / 0.9f);

            loadingText.text = "Loading... " + (int)(_progress * 100f) + "%";

            //Debug.Log("Loading... " + (int)(_progress * 100f) + "%");

            yield return null;
        }

        float t = 0f;

        while (t < 1f)
        {
            t += Time.deltaTime;
            float a = curve.Evaluate(t);
            img.color = new Color(0f, 0f, 0f, a);
            loadingText.color = new Color(1f, 1f, 1f, a);
            yield return 0;
        }

        //SceneManager.LoadScene(scene);
        operation.allowSceneActivation = true;
    }
}

and as the title say, the loadingText don’t update to show what is in the function

I don’t know if this would help perhaps?

Canvas.ForceUpdateCanvases();

I put it like this

private void OnEnable()
    {
        Canvas.ForceUpdateCanvases();
    }

and no results

I think you have to force update AFTER you’ve edited the text though? if you have multiple changes you would have multiple updates? Just a random guess though :slight_smile:

still no changes

It seems my text was not big enough to display all the content