Start a Unity Project
Create a Unity project from the Unity Hub. Add the following DLLs for reference within the project:
BouncyCastle.dll
FM.LiveSwitch.dll
FM.LiveSwitch.AudioProcessing.dll
FM.LiveSwitch.Opus.dll
FM.LiveSwitch.Unity.dll
FM.LiveSwitch.Vpx.dll
FM.LiveSwitch.Yuv.dll
Unity.IO.Compression.dll
These DLLs supply the necessities for a LiveSwitch Unity project:
- Codecs
- Image converters
- Video and audio capture
- DTLS security
Important
- The scripting backend for LiveSwitch’s Unity SDK must be Intermediate Language to C++ (IL2CPP) for mobile platforms. Read more on IL2CPP here.
- To optimize audio latency, in the Unity editor, go to Edit > Project Settings > Audio and set the DSP Buffer Size field as Best latency.
Use the following files to build the ILC2CPP scripting backend:
libopusfm_stub.c
libvpxfm_stub.c
libyuvfm_stub.c
You might need additional files and steps depending on the platform you want for your Unity project. Find these files in the Libraries
directory of your install and the plugins
directory of the Unity example.
Apply DLLs and Other Files
Refer here for instructions on how to apply DLLs to your unity project. Note that Unity's C# compiler supports a .NET 4.6 equivalent.
Windows
Use the following files for a Windows build in Unity:
libaudioprocessingfm.dll
libopusfm.dll
libvpxfm.dll
libyuvfm.dll
Use a set of these DLL files each for both x64 and x86 CPU architectures.
macOS
macOS isn't supported.
Linux
You need the following SO files for a Linux build in Unity:
liblibaudioprocessingfm.so
liblibopusfm.so
liblibvpxfm.so
liblibyuvfm.so
iOS
You need the following A files for an iOS build in Unity:
libopusfm-iOS.a
libvpxfm-iOS.a
libyuvfm-iOS.a
In your build settings, do the following:
- Under Player > iOS > Other Settings, add description in the Camera Usage Description field.
- Under Player > iOS > Other Settings, add description in the Microphone Usage Description field.
After generating the Xcode project for iOS, set the required build permissions using chmod a+x MapFileParser.sh
.
In your Xcode target settings for Unity-iPhone, under Signing & Capabilities, choose a provisioning file and team.
In your Xcode target settings for UnityFramework, do the following:
- Under Build Settings > Build Options, set Enable Bitcode to No.
- Under Build Phases > Link Binary with Libraries, move the native LiveSwitch Libraries to the top of the list:
libopusfm-iOS.a
libvpxfm-iOS.a
libyuvfm-iOS.a
Important
Ensure that you apply the Build Phases change to the UnityFramework project.
If you don't have the LiveSwitch libraries listed at the top of the list, following error occurs:
Could not initialize VPX encoder. ABI version mismatch
Note
These steps are necessary for the first build and any subsequent builds that use the replace Xcode project generation mode. Read more here. Using the append
Xcode project generation mode doesn't overwrite these changes.
Android
You need the following SO files for an Android build in Unity:
libaudioprocessingfm.so
libopusfm.so
libvpxfm.so
libyuvfm.so
Use a set of these SO files each for the Arm64-v8a, Armeabi-v7a, and x86 CPU architectures.
If you are looking to transfer to an older Unity version, such as from Unity 2019 to Unity 2018, make sure that you reset the packages to avoid library corruption. Reset the packages by going to Help > Reset Packages by Default.