public IEnumerator LoadRemoteImage(Cubequad.c_Data data)
    {
        string path = data.imageUrl;

        Texture2D texture = null;

        // Get the remote texture

#if UNITY_2017_4_OR_NEWER
        var webRequest = UnityWebRequestTexture.GetTexture(path);
        yield return(webRequest.SendWebRequest());

        if (webRequest.isNetworkError || webRequest.isHttpError)
        {
            Debug.LogError("Failed to download image [" + path + "]: " + webRequest.error);
        }
        else
        {
            texture = ((DownloadHandlerTexture)webRequest.downloadHandler).texture;
        }
#else
        WWW www = new WWW(path);
        yield return(www);

        texture = www.texture;
#endif

        if (texture != null)
        {
            var rec = new Rect(0, 0, texture.width, texture.height);
            cellImage.sprite = Sprite.Create(texture, rec, new Vector2(0, 1), 100);
            //cellImage.sprite = Sprite.Create(texture, new Rect(0, 0, data.imageDimensions.x, data.imageDimensions.y), new Vector2(0, 0));
            cellImage.preserveAspect = true;
        }
        else
        {
            ClearImage();
        }
    }
    public void CreateCanvas(string Nome, string Ingredienti, string Allergeni, string UrlFoto, string[] EsclIngredienti, float Prezzo, bool ConFoto, int Idart, string note, string Guid)
    {
        ingredienti.text = null;
        Immagine.gameObject.SetActive(false);
        cellImage.sprite        = null;
        piattoCorrente          = new Comanda.Ordine();
        piattoCorrente.Nome     = Nome;
        piattoCorrente.Prezzo   = Prezzo;
        piattoCorrente.Quantità = 1;
        piattoCorrente.EsclusioneIngredienti = EsclIngredienti;
        piattoCorrente.IDart = Idart;
        piattoCorrente.Guid  = Guid;
        Container.SetActive(true);
        nome.text   = Nome;
        prezzo.text = Prezzo + " €";
        if (ContentCreator.Db == 1)
        {
            if (UrlFoto != null)
            {
                if (UrlFoto.Length >= 50)
                {
                    byte[] b64_bytes = System.Convert.FromBase64String(UrlFoto);

                    var tex = new Texture2D(1, 1);
                    tex.LoadImage(b64_bytes);
                    if (tex != null)
                    {
                        var rec = new Rect(0, 0, tex.width, tex.height);
                        cellImage.sprite = Sprite.Create(tex, rec, new Vector2(0, 1), 100);
                        //cellImage.sprite = Sprite.Create(texture, new Rect(0, 0, data.imageDimensions.x, data.imageDimensions.y), new Vector2(0, 0));
                        cellImage.preserveAspect = true;
                    }
                }
                else
                {
                    RicercaFoto.gameObject.SetActive(true);
                    CallWebService.MMS.getImage("AAA", ContentCreator.Restaurant, Guid);
                }
            }
            else
            {
                Immagine.gameObject.SetActive(false);
            }
        }
        if (ConFoto)
        {
            Immagine.gameObject.SetActive(true);
            if (ContentCreator.Db == 0)
            {
                LogoData = new Cubequad.c_Data()
                {
                    imageUrl        = UrlFoto,
                    imageDimensions = new Vector2(643f, 227f)
                };
                try
                {
                    SetData(LogoData);
                }
                catch
                {
                    Immagine.gameObject.SetActive(false);
                }
            }
        }
        else
        {
            Immagine.gameObject.SetActive(false);
        }
        if (Ingredienti != null && Ingredienti.Length > 4)
        {
            containerIngredienti.gameObject.SetActive(true);
            ingredienti.text = Ingredienti;
        }
        if (Allergeni != null && Allergeni.Length > 3)
        {
            ContainerAllergeni.SetActive(true);
            allergeni.text = Allergeni;
        }
        else
        {
            ContainerAllergeni.SetActive(false);
            allergeni.text = "No";
        }
        if (note != null && note.Length > 3)
        {
            ingredienti.text = note + '\n' + Ingredienti;
        }
    }
 public void SetData(Cubequad.c_Data data)
 {
     _loadImageCoroutine = StartCoroutine(LoadRemoteImage(data));
 }