Skip to content

Instantly share code, notes, and snippets.

@icywind
Last active March 23, 2020 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icywind/597d1b6bfbcb5036645a18ffbe04fbea to your computer and use it in GitHub Desktop.
Save icywind/597d1b6bfbcb5036645a18ffbe04fbea to your computer and use it in GitHub Desktop.
RemoteAssistantAR
private void ShareRenderTexture()
{
if (BufferTexture == null) // offlined
{
return;
}
Camera targetCamera = Camera.main; // AR Camera
RenderTexture.active = targetCamera.targetTexture; // the targetTexture holds render texture
Rect rect = new Rect(0, 0, targetCamera.targetTexture.width, targetCamera.targetTexture.height);
BufferTexture.ReadPixels(rect, 0, 0);
BufferTexture.Apply();
byte[] bytes = BufferTexture.GetRawTextureData();
// sends the Raw data contained in bytes
monoProxy.StartCoroutine(PushFrame(bytes, (int)rect.width, (int)rect.height,
() =>
{
bytes = null;
}));
RenderTexture.active = null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment