Display webcamtexture via sprite.texture, error at GetPixels(). Help :)

Hi guys,

I’m currently trying to get the camera feed and display onto the scene using sprite.texture. However, I’m stuck with an error at webCamTexture.GetPixels();. The error during runtime, when the function is called.

below is the error and a snippet of my code, please help thanks!!! :slight_smile:


Error: 
Texture rectangle is out of bounds (0 + 16 > 0)
UnityEngine.WebCamTexture:GetPixels(Int32, Int32, Int32, Int32)


Texture2D disp = new Texture2D(webCamTexture.width, webCamTexture.height, TextureFormat.ARGB32, false);
Color [] output = webCamTexture.GetPixels();//0, 0, disp.width, disp.height);
disp.SetPixels(output);
disp.Apply();

Update:
I resolved my “being stuck”, via an alternate solution. I used quads to display the output instead of using sprite.
Unfortunately, don’t remember why I was getting the error with GetPixels. Probably to do with a bad initialisation of the webcamtexture or something.