- Home /
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.
I am not sure how to do this but have you tried drawing the rawimage to a rawimage component of the UI system? I am not sure if that is what you need but I suppose it might be an idea.
Answer by TheKnightsofUnity · Nov 26, 2018 at 03:10 PM
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
Your answer
Follow this Question
Related Questions
change variable and Texture2D 1 Answer
Editing Texture during Run time causing Unity Editor to Crash 1 Answer
Loading a texture from a local image file? 1 Answer
how compare 2 imagens 1 Answer
Problems setting up a Texture2D 2 Answers