- Home /
 
              This post has been wikified, any user with enough reputation can edit it. 
            
 
             
               Question by 
               pmod90 · Nov 25, 2013 at 10:54 PM · 
                texturewebcamtexturegetpixels  
              
 
              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.
               Comment
              
 
               
              Did you figure out what the issue to your problem is? I'm currently experiencing the same issue.
Answer by b099l3 · Jan 23, 2016 at 01:31 AM
Make sure you are calling GetPixel in your update method and not in your start method.
Your answer