Unity is widely used for building interactive, real-time applications across multiple platforms, including desktop, mobile, and XR environments. As demand for ultra-low-latency streaming grows—especially for gaming, AR/VR, and real-time collaboration—WebRTC has become a natural choice for streaming inside Unity applications.
Ant Media Server provides native WebRTC support, making it possible to publish and play real-time streams directly from Unity with sub-second latency. Using Ant Media’s Unity WebRTC SDK, developers can stream live audio and video across platforms such as Windows, macOS, iOS, Android, and web browsers.
This guide explains how to use the Unity WebRTC SDK with Ant Media Server, covering supported capabilities, prerequisites, sample projects, and platform-specific configuration steps for desktop and mobile environments.
Table of Contents
Capabilities of Unity WebRTC SDK
Ant Media’s Unity WebRTC SDK enables real-time audio and video streaming directly within Unity applications. The SDK supports the following core capabilities across multiple platforms.
Supported Streaming Capabilities
- Publish WebRTC streams from Unity applications to Ant Media Server
- Play WebRTC streams published by other clients or devices
- Multi-party conferencing, enabling multiple publishers and viewers in the same session
Cross-Platform Support
The SDK works across a wide range of environments, including:
Streams published from one platform can be played on other platforms seamlessly, enabling truly cross-platform real-time streaming. Production deployments handling thousands of concurrent viewers across multiple device types require horizontal WebRTC scaling architectures that maintain consistent sub-second latency regardless of geographic distribution or viewer count. This becomes particularly critical when Unity applications need to support simultaneous streaming to desktop browsers, mobile devices, and native applications without protocol conversion overhead or quality degradation across heterogeneous network conditions.
Prerequisites for Unity WebRTC SDK
Before using the Unity WebRTC SDK with Ant Media Server, ensure that the following prerequisites are met.
Requirements
- Unity installed on your development machine
- Ant Media Server running and accessible
- Unity WebRTC SDK downloaded from your Ant Media account
The Unity WebRTC SDK is free to download. It is available to users on the Pay-As-You-Go plan as well as Enterprise subscribers. After downloading the SDK, extract the package to a local directory.
This guide assumes basic familiarity with Unity and that Ant Media Server is already installed and running.
Run the Sample Unity WebRTC SDK App
After downloading and extracting the Unity WebRTC SDK, you can run the included sample application to test publishing and playing WebRTC streams.
Open the Sample Project
- Launch Unity Hub.
- Click Open and select the extracted Unity WebRTC SDK sample project.
- Open the project in the Unity Editor.

Select a Scene
The sample project includes multiple scenes for different streaming scenarios:
- Sendonly – Publish a WebRTC stream from Unity
- Recvonly – Play an existing WebRTC stream
- Multi_sendrecv – Multi-party conferencing (publish and play)
Open the scene that matches your use case.

Configure Signaling URL
Set the Signaling URL, which is the WebSocket endpoint of your Ant Media Server:
wss://<server-domain-or-ip>:5443/<app-name>/websocketMake sure SSL is enabled on Ant Media Server when using secure WebSocket. The signaling URL establishes the bidirectional communication channel for WebRTC session negotiation, including SDP offer-answer exchange and ICE candidate gathering. Understanding WebSocket signaling mechanics becomes essential when debugging connection failures, implementing custom authentication flows, or optimizing session establishment latency. Unity developers working with WebRTC need to grasp how signaling differs from media transmission, why secure WebSocket connections are required for production deployments, and how signaling server architecture affects overall streaming reliability and peer connection success rates.

Set Stream or Room Identifier
- For Sendonly and Recvonly scenes, set the Channel ID to your stream ID.
- For the Multi_sendrecv scene, set the Channel ID to the room name.

Start Streaming or Playback
After completing the configuration:
- Click Start to begin publishing or playing the stream.
- If configured correctly, WebRTC streaming will start with ultra-low latency.
Android Configuration
Additional configuration is required to enable WebRTC streaming on Android when using the Unity WebRTC SDK.
Platform Requirements
- Android 7.0 (API level 24) or higher
- ARM64 architecture
Step 1: Configure Native Plugin Architecture
- Select
libSoraUnitySdk.soin the Project window. - In the Inspector, set:
- CPU →
ARM64
- CPU →

Step 2: Set Graphics API to Vulkan
- Go to Player Settings → Android → Other Settings.
- Under Graphics APIs, remove OpenGLES if present.
- Add Vulkan and move it to the top of the list.

Step 3: Set Minimum Android Version
- Navigate to Player Settings → Android → Other Settings.
- Set Minimum API Level to:
Android 7.0 'Nougat' (API level 24)
Step 4: Configure Target Architectures
- In Player Settings → Android → Other Settings.
- Under Target Architectures, enable:
- ✅ ARM64

Build and Run
After completing these steps:
- Switch the build platform to Android
- Connect an Android device or emulator
- Build and run the project
Once deployed, the Unity application will be able to publish or play WebRTC streams using Ant Media Server on Android devices.
iOS Configuration
Additional configuration is required to enable WebRTC streaming on iOS when using the Unity WebRTC SDK.
Platform Requirements
- iOS 10.0 or later
- Xcode installed and configured

Step 1: Configure Native Plugins
Unity requires platform-specific plugin settings for iOS.
Configure libwebrtc.a
- Select
libwebrtc.ain the Project window. - In the Inspector:
- Uncheck Any Platform
- Under Include Platforms, enable iOS only
Configure libSoraUnitySdk.a
- Select
libSoraUnitySdk.ain the Project window. - In the Inspector:
- Uncheck Any Platform
- Under Include Platforms, enable iOS only

Step 2: Set Minimum iOS Version
- Go to Player Settings → Other Settings.
- Set Target Minimum iOS Version to: iOS 10 or higher

Step 3: Configure Camera Permission (Optional)
If your Unity scene publishes video using the device camera:
- Go to Player Settings → Other Settings.
- Set Camera Usage Description with a brief explanation, for example:
Camera access is required for live video streaming.Note: This is not required for Recvonly scenes or scenes that do not use the camera.

Step 4: Configure Microphone Permission (Optional)
If your application captures audio:
- Go to Player Settings → Other Settings.
- Set Microphone Usage Description with a brief explanation, for example:
Microphone access is required for live audio streaming.Note: This is not required for Recvonly scenes or scenes that do not use audio input.

Frequently Asked Questions
Is the Unity WebRTC SDK free to use?
Yes. The Unity WebRTC SDK is free to download and is available to users on the Pay-As-You-Go plan as well as Enterprise subscribers. No additional licensing is required to start using the SDK.
Which streaming protocol does the Unity SDK use?
The Unity WebRTC SDK uses WebRTC for both publishing and playback, enabling ultra-low-latency audio and video streaming when used with Ant Media Server.
What is the signaling URL and why is it required?
The signaling URL is the WebSocket endpoint of Ant Media Server used to exchange WebRTC signaling messages. It is required to establish the peer connection between the Unity application and Ant Media Server.
What is the difference between Sendonly, Recvonly, and Multi_sendrecv scenes?
Sendonly is used to publish a WebRTC stream from Unity, Recvonly is used to play an existing WebRTC stream, and Multi_sendrecv enables multi-party conferencing where clients can both publish and receive streams.
Do I need SSL to use WebRTC streaming in Unity?
Yes. Secure WebSocket (wss) and HTTPS are required by modern browsers and platforms for WebRTC. SSL must be enabled on Ant Media Server to use WebRTC streaming reliably. Production WebRTC deployments require proper TLS certificate configuration including certificate chain validation, domain name verification, and proper cipher suite selection for encrypted media transmission. Unity developers must ensure their Ant Media Server instances use valid SSL certificates from trusted certificate authorities, configure correct WebSocket secure endpoints, and handle certificate renewal workflows to prevent WebRTC connection failures in production environments where browser security policies strictly enforce HTTPS requirements.
Conclusion
Now, you are ready to stream low latency in a versatile unity environment on various platforms including iOS and Android. WebRTC streaming in Unity has never been easier than this.
You have more options for publishing with our SDK. Please check our other guides for publishing with SDKs:
- How to Use WebRTC SDK in Native Android App?
- Easy-to-use WebRTC iOS SDK Lets You Build WebRTC iOS App with 4 Lines of Code
You may also want to check out Leap Gaming: Developer of ultra-realistic 3D games deployable on multiple platforms case study.
If you have any questions, don’t hesitate to contact us.
Estimate Your Streaming Costs
Use our free Cost Calculator to find out how much you can save with Ant Media Server based on your usage.
Open Cost Calculator