Load texture from url image in RawImage of Image of UI

Hi everyone,

I would like to ask you how i can load on Raw Image texture from url.

This code doesn’t work for me

private string url = "www.mydomain.com/images/image.jpg";

public loadTheImage(){
            RawImage theRawImage = (RawImage)gameObject.GetComponent(typeof(RawImage));
            theRawImage.texture = url;
}

it gives this error “error CS0029: Cannot implicitly convert type string' to UnityEngine.Texture’”

Any idea.

Thank you in advance

ki_ha1984

you have to load the texture yourself with the WWW class and then assign the texture you get. the Image has no idea how to take a string and make it a texture.

1 Like

Thank you for your answer phil-Unity.

I know how to make texture from www, But the problem is that the RawImage gives only for read the maintexture and i have to use the texture attribute, which does not work with www as the main texture.

Any idea ?

Thank you