Search Unity

Webgl - update label text

Discussion in 'Editor & General Support' started by giuliofelix, Mar 31, 2021.

  1. giuliofelix

    giuliofelix

    Joined:
    Jan 21, 2016
    Posts:
    2
    Hi all,
    i've got a problem with a WebGL project.
    In this project i have a method that post some data to a webserver with a www
    ---------------------------------------------post data
    https://xxxxxxxxx.it/web/packaging/...ht=100&lenght=1000&materials=prova&notes=nota di prova&CameraposX=10&CameraposY=10&CameraposZ=10&Cameranear=10&Camerafar=10&Camerafov=10&Imglabel=http://xxxxx.it/web/logo.png&Imggrafica=http://datafood3d.it/web/logo.png&Bgr=4&Bgg=35&Bgb=35&id=65


    and then call an Unitywebrequest to download a json spool from web site after 4 seconds
    ---------------------------------------------------------get data
    https://xxxxxx.it/web/packaging/getmodel?id=65

    i transform the downloaded spool in a Object
    ---------------------------------------------------------write text
    Modello P = JsonUtility.FromJson<Modello>(recentData);

    with the P object i change the text in a label.

    string Nota = P.Bgb.ToString() + " " + P.Bgg.ToString() + " " + P.Bgr.ToString();
    getNoteText.text = Nota;



    string web = "https://xxxxxx.it/web/packaging/addupdatemodel" + variabili;
    WWW ncal = new WWW(web);
    yield return ncal;
    if (string.IsNullOrEmpty(ncal.error))
    {
    if (ncal.text != "[]")
    {
    Debug.Log("Inserito correttamente");
    string id = getIDText.text;
    StartCoroutine(Foo(id)); ///wait 4 seconds and then download datta

    }
    }
    IEnumerator Foo(string id)
    {
    /
    yield return new WaitForSeconds(4f); // Wait four seconds
    StartCoroutine(Getmodello2(id, this.ResponseCallback)); // Download the data again
    }

    When i test in the editor it's all ok ....,the text in the label change correctly at every click.
    When i export the WEBGL project and test in the web the project work but the label don't update immediately,i had to add a new button that only download json,create model object and after update the label text ,after some click the text update not at the first click.