I’m having trouble displaying a WebCamTexture in a 2D project.
I tried two ways that were similar to what worked for a 3D project, but nothing is rendered. In he attached pic link, I tried adding a 3D Plane, and assigning the WebCamTexture to it. Nothing. Also tried adding a UI Panel, then adding a Mesh Renderer to the panel, still nothing…
webCamTexture = new WebCamTexture();
GetComponent().material.mainTexture = webCamTexture;
webCamTexture.Play();
Well I’ve found something at least. I changed the Inspector to Scene View, and then from 2D to 3D, then panned around. The image is on the back of my plane! But its there… Coping with that. But at least there is an image someplace.
still stuck though. The 3D plane does not appear in the Game view. Can’t get it to. Nor get the image on the UI Panel.
Got some great help on IRC (after pulling out their teeth).
I added a RawImage to the UI scene. Then…
GetComponent<UnityEngine.UI.RawImage>().texture = webCamTexture;
2 Likes
Hi! I wanted to thank you for your great help!!
I was having trouble to use my Android phone cam in a 2D Project. In my case, I was trying to use a Plane and could see my camera, but it was darker (even after adding light to the scene, didn`t work).
I combined your solution with this tutorial below and worked fine! Thanks a lot
So helpful! Thank you so much.