Try Live Demo

Unity’s popularity has been rising in the last decade thanks to its multiplatform capabilities. Lately, thanks to AR/VR/XR developments, its usage and functionality have increased further. With the need for real-time latency in streaming, the need for Unity WebRTC solutions has also increased.

It’s now possible to stream any content with WebRTC streaming in Unity with Ant Media Server!

You can develop many different types of applications, from gaming to music players with Unity. And now, you can stream from your Unity application in ultra-low latency using Ant Media’s free Unity WebRTC SDK.

Capabilities of Unity WebRTC SDK

You can achieve publishing, playing, and conferencing capabilities in various environments such as Windows, iOS, Android, and macOS.

  • Could publish WebRTC stream which could be played by other Android devices, iOS devices, and browsers (mobile or desktop).
  • Could play WebRTC stream which is published by other Android devices, iOS devices, and browsers (mobile or desktop).

Let’s see how to stream in a such versatile environment with ultra-low latency.

Prerequisites for Unity WebRTC SDK

Unity WebRTC SDK is free to download. You can access them by subscribing pay as you go plan for free. If you’re an enterprise user, it will be also available for you to download on your subscription page. Anyway, after you download the Unity WebRTC SDK, you can just unzip the file.  This WebRTC Streaming In Unity guide assumes you have installed Unity.

Run the Sample Unity WebRTC SDK App

Once you downloaded the sample Unity WebRTC SDK, open unity and open the downloaded sample. After opening the sample, add the scene you want to: Sendonly, Recvonly, Multi_sendrecv.

  • Sendonly is publish only.
  • Recvonly is to play streams.
  • Multi_sendrecv is for conferences.

WebRTC Streaming In Unity

After selecting the scene, set your signaling URL which is the WebSocket URL of your Ant Media Server:

Unity WebRTC Streaming

After setting the signaling URL, we are ready to go. Now set the channel id which is your stream id for scenes sendonly and recvonly. But it is your room name in the conference which is multi_sendrecv scene.

WebRTC Streaming In Unity

Lastly, click to start streaming/playing to start ultra-low latency streaming/playing.

Ultra Low latency

For the desktop environment, that is enough to start streaming/playing but for mobile platforms, iOS /Android requires a few more steps. Let’s see additional steps to enable mobile platforms to have WebRTC streaming in Unity.

Android

Change the CPU to ARM64 in Platform settings-> Android settings in the libSoraUnitySdk.so inspector.

Unity Webrtc Unity

Set the Graphics APIs to Vulkan

Put Vulkan first in the Graphics APIs in Player Settings-> Other Settings.

Vulkan

Set Android 7.0’Nougat’ (API level 24) or higher in Minimum API Level

Select Android 7.0’Nougat’ (API level 24) or above in Player Settings-> Other Settings-> Minimum API Level.

version

Set ARM64 in Target Architectures.

Check ARM64 in Player Settings-> Other Settings-> Target Architectures.

arm64

iOS

Change the settings of iOS Plugin

libwebrtc.a’s Inspector-> Select Platform for plugin-> Uncheck Any Platform and set Include Platforms to check only iOS.

iosplatform

Also, do the same thing for the iOS plugin.

libSoraUnitySdk.a Inspector-> Select Platform for plugin-> Uncheck Any Platform and set Include Platforms to check only iOS.

IOS unity Webrtc

Set Target Minimum iOS Version to 10.0 or higher

Please set 10.0 or higher in Player Settings-> Other Settings-> Target Minimum iOS Version.WebRTC Unity Sdk

If you want to use the camera, you need to set the permission

Please set a comment for using the camera in Player Settings-> Other Settings-> Camera Usage Description. (Not required for recvonly and Capture Unity Camera because these scenes or unity capture camera do not use a camera)

low latency

If you want to use a microphone, you need to set the authority.

Set a comment for using the microphone in Player Settings-> Other Settings-> Microphone Usage Description. (Not required for recvonly and Capture Unity Camera because these scenes or unity capture camera do not use a camera)

low latency

You are set for WebRTC streaming in Unity!

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:

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.

Categories: Tutorial

chatsimple
Warning: Undefined array key "promocode" in /home/mirror.antmedia.io/public_html/wp-content/themes/hestia-child/footer.php on line 70