胡佳骏 34e62101b5 项目提交 | 1 year ago | |
---|---|---|
.. | ||
NvCodec | 1 year ago | |
WebRTCPlugin | 1 year ago | |
WebRTCPluginTest | 1 year ago | |
cmake | 1 year ago | |
gl3w | 1 year ago | |
glad | 1 year ago | |
libcxx | 1 year ago | |
tools | 1 year ago | |
unity | 1 year ago | |
.clang-format | 1 year ago | |
CMakeLists.txt | 1 year ago | |
CMakePresets.json | 1 year ago | |
README.md | 1 year ago |
This guide will cover building and deploying the native plugin com.unity.webrtc
depends on.
Install dependencies to make development environment.
On windows, first, the build process use the clang compiler. To install clang, see MSDN. And chocolatey is used to install.
# Install CUDA
choco install cuda --version=11.0.3
# Install Windows SDK
# WARNING: If you have versions of Windows SDK earlier than Version 1809,
# compiling the plugin will fail. Make sure to uninstall earlier versions.
choco install -y vcredist2010 vcredist2013 vcredist140 windows-sdk-10-version-1809-all
# Install Vulkan
choco install vulkan-sdk --version=1.2.182.0
# Install CMake 3.22.3
choco install cmake -y --version=3.22.3
# Install 7zip (used to extract Google's webrtc library after download)
choco install 7zip
# Setting up environment variables
setx CUDA_PATH "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0" /m
setx VULKAN_SDK "C:\VulkanSDK\1.2.182.0" /m
The below commands shows the build process developing environment on Ubuntu 20.04
.
#install packages
sudo apt install -y vulkan-utils libvulkan1 libvulkan-dev libglib2.0-dev python3-venv lld clang-10 freeglut3-dev ninja-build
# Install CUDA SDK
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /"
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install -y nvidia-driver-510 libnvidia-gl-510 libnvidia-decode-510 libnvidia-encode-510
sudo apt install -y cuda-toolkit-11-0
# Install CMake 3.22.3
sudo apt install -y libssl-dev
sudo apt purge -y cmake
wget https://github.com/Kitware/CMake/releases/download/v3.22.3/cmake-3.22.3.tar.gz
tar xvf cmake-3.22.3.tar.gz
cd cmake-3.22.3
./bootstrap && make && sudo make install
On macOS, homebrew is used to install CMake. XCode version 11.0.0 or higher is used but Xcode 12 would not work well.
# Install CMake
brew install cmake
On macOS, homebrew is used to install CMake. XCode version 11.0.0 or higher is used but Xcode 12 would not work well.
On Ubuntu (WSL2 on Windows is also working well),
# Install Android NDK r21b
wget https://dl.google.com/android/repository/android-ndk-r21b-linux-x86_64.zip
# Set Android NDK root path to `ANDROID_NDK` environment variable
echo "export ANDROID_NDK=~/android-ndk-r21d/" >> ~/.profile
# Install CMake 3.22.3
sudo apt install -y libssl-dev
sudo apt purge -y cmake
wget https://github.com/Kitware/CMake/releases/download/v3.22.3/cmake-3.22.3.tar.gz
tar xvf cmake-3.22.3.tar.gz
cd cmake-3.22.3
./bootstrap && make && sudo make install
# Install pkg-config, zip
sudo apt install -y pkg-config zip
To build plugin, you need to execute command in the BuildScripts~
folder.
LNK1120
, LNK2001
or LNK2019
errors while running this build script, it's possible that you may need to open Plugin~/build64/webrtc.sln
and build from within Visual Studio 2019 instead. You can also use it for development. (#441)Alternatively, after the script has been run, a project ready for your IDE or other build tools is ready for you to use/build with (the name of the folder differs based on the target platform, check the script for more details).
When you run the build, webrtc.dll
will be placed in Packages\com.unity.webrtc\Runtime\Plugins\x86_64
. You should then be able to verify the following settings in the Unity Inspector window.
WARNING: If "Load on startup" is not ticked, your editor will crash when running your project. This may become unticked after you make a change to the plugin. (#444)
The WebRTC
project properties must be adjusted to match your environment in order to build the plugin.
Set the Unity.exe path under Command
and the project path under Command Arguments
. Once set, during debugging the Unity Editor will run and breakpoints will be enabled.