79652603

Date: 2025-06-04 10:45:43
Score: 0.5
Natty:
Report link

Unfortunately, you cannot directly stream the camera feed using both ARFoundation and Agora. A workaround for this is to save the camera output into a `RenderTexture` inside Unity and use that. You can then feed this into Agora. Just make sure to disable the camera capture of Agora if that is active, and call this method in your `Update()` function:

Texture2D frameTexture;

void CaptureFrame()
{
    RenderTexture rt = new RenderTexture(Screen.width, Screen.height, 24);
    ScreenCapture.CaptureScreenshotIntoRenderTexture(rt);
    RenderTexture.active = rt;

    frameTexture = new Texture2D(rt.width, rt.height, TextureFormat.RGBA32, false);
    frameTexture.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
    frameTexture.Apply();

    RenderTexture.active = null;
    rt.Release();
}

Here is the documentation from Agora's side on how to achieve this:
- Agora's Github for Unity: https://github.com/AgoraIO-Extensions/Agora-Unity-Quickstart
- Custom Video Source Docs ( using Agora's native SDK ) : https://docs.agora.io/en/video-calling/overview/product-overview

Reasons:
  • Blacklisted phrase (1): how to achieve
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: KBaker