How to convert a RawImage to a texture

I am trying to input a WebCamTexture into a materials mainTexture. I have converted the webcamtexture to a rawImage. How can I change rawImage to texture ?
Seems to be quite difficult.

Hello there, @richardzzzarnold!

You can retrieve Texture from RawImage by using RawImage.texture property.
However, in your case we would suggest to directly apply WebCamTexture to a material:

public Material material;

private void Start()
{
    WebCamTexture wct = new WebCamTexture();
    material.mainTexture = wct;
    wct.Play();
}

Specified material has to use Unlit/Texture shader.
Don’t forget to call WebCamTexture.Play() to start the camera.


All the best,

The Kinghts of Unity