How to get rgb from Texture2D faster?
I'm trying to render camera to a Texture2D and sending data via UDP to my C++ application:
 void getCameraImg()
         {   
             
             
             RenderTexture rt = new RenderTexture(resWidth, resHeight, 24);
             camera.targetTexture = rt;
             Texture2D screenShot = new Texture2D(resWidth, resHeight, TextureFormat.RGB24, false);
             camera.Render();
             RenderTexture.active = rt;
             screenShot.ReadPixels(new Rect(0, 0, resWidth, resHeight), 0, 0);
             camera.targetTexture = null;
             RenderTexture.active = null;
             Destroy(rt);
     
             Color[] pixels = screenShot.GetPixels();**//(PROBLEM HERE)**
     
     
               for(int y=0;y<resHeight; y++)
               {
                   for(int x=0;x<resWidth; x++)
                   {
     
                      imageData[(resHeight - y - 1) * resWidth + x] = System.Convert.ToByte((char)((int)pixels[resWidth*y+x].grayscale*255)); 
                     // System.Convert.ToByte((char)((int)(screenShot.GetPixel(x, y).grayscale * 255)));
                   }
               }
     
             Destroy(screenShot);
     
     
     
         }
screenShot.GetPixels() is too slow, FPS falls to 15; screenShot.GetPixel(x, y) in loop is even worse (about 8 fps); is there a way to get access to rgb data of Texture2D directly from memory?
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                