WebcamTexture GetPixel not working

I am using a Logitech Webcam for my unity project.I am trying to get rgb values for my webcamtexture.But all I get is 0,0,0,1.Here’s my code:

  WebCamDevice[] devices = WebCamTexture.devices;
        WebCamTexture webcamTexture = new WebCamTexture();
        if (devices.Length > 0) {
            webcamTexture.deviceName = devices[1].name;
			print (webcamTexture.deviceName);
			webcamTexture.requestedHeight = 400;
			webcamTexture.requestedWidth = 400;
            webcamTexture.Play();
			print(webcamTexture.isPlaying);
			print(webcamTexture.GetPixel(200,200));
			while(pl!=100)
			{
			if(webcamTexture.didUpdateThisFrame == true)
			{
				print(webcamTexture.height);
					print(webcamTexture.GetPixel(200,200));
			pl++;
				}
			}
        }

The Webcam was successfully detected(even the webcam light was on) but I am always getting 0,0,0 as my rgb values when I use GetPixel.Please help.

Did you figure out what the issue to your problem is? I'm currently experiencing the same issue.

1 Answer

1

Make sure you are calling GetPixel in your update method and not in your start method.