public void SendTexture() { if (sendTexture == null) { sendTexture = new Texture2D(sendRenderTexture.width, sendRenderTexture.height, TextureFormat.RGB24, false); } RenderTexture.active = sendRenderTexture; sendTexture.ReadPixels(new Rect(0, 0, sendRenderTexture.width, sendRenderTexture.height), 0, 0, false); //sendTexture.Apply(false); byte[] packet; if (useJpgEncodeSend) { JPGEncoder encoder = new JPGEncoder(sendTexture, jpgQuality); encoder.doEncoding(); packet = encoder.GetBytes(); } else { packet = sendTexture.EncodeToPNG(); } if (packet.Length > 0) { udp.SendPacket(packet); } }
public void SendTexture() { if (sendTexture == null) { sendTexture = new Texture2D(sendRenderTexture.width, sendRenderTexture.height, TextureFormat.RGB24, false); } RenderTexture.active = sendRenderTexture; sendTexture.ReadPixels(new Rect(0, 0, sendRenderTexture.width, sendRenderTexture.height), 0, 0, false); //sendTexture.Apply(false); byte[] packet = sendTexture.EncodeToPNG(); udp.SendPacket(packet); }