problem nyartoolkits ann webcam resolution

hi,

I’m having problems with the webcam resolution at my Project with nyartoolkit.

WebCamDevice devices= WebCamTexture.devices;

	WebCamTexture w;
	if (devices.Length > 0)
	{			
		w=new WebCamTexture(320, 240, 15);

in this case if the webcam isn’t at 320x 240 resolution when i play the game it give me a error:
Input color array length needs to match width * height, but 76800!= 640 * 480
UnityEngine.WebCamTexture:GetPixels32(Color32)

i think the webcam are at 640x480 and 76800 are 320x240.

But how i can solve this problema?

can i know the resolution of webcam before i créate the new WebCamTexture() so i can créate a
new WebCamTexture(webcamWidth, webcamHeight, 15);

Thanksyou.

You’ll need your WebCamTexture’s resolution to match your webcam’s resolution exactly in order for this to work. Fortunately, it tells you that it’s looking for 640 by 480, so simply instantiate your WebCamTexture with those coordinates and it will work.