This project constitutes a Unity native plugin and a set of Unity C# script components allow third parties to incorporate Servo browser windows into Unity scenes.
For more background information, see the blog post at https://blog.mozvr.com/a-browser-plugin-for-unity/
src/ServoUnity
, with a sample scene at src/ServoUnity/Assets/ExampleScene.unity
.src/ServoUnityPlugin
.src/ServoUnity/Assets/Plugins
.src/ServoUnity/Assets/Scripts
.The license file sets out the full license text.
The code is licensed under the MPL2.
This license is compatible with use in a proprietary and/or commercial application.
What | Minimum version | Where to download |
---|---|---|
Unity | 2019.3 | https://unity.com |
For macOS: Xcode tools | https://developer.apple.com | |
For Windows: Visual Studio 2019 (Community or Professional) | https://visualstudio.microsoft.com/vs/ |
During this development phase of the project, only macOS is supported.
Servo itself enters the plugin through the wrapper library libsimpleservo2
. You can find a binary build of libsimpleservo2 at https://github.com/philip-lamb/servo/releases, or you can build it from source. This fork of the servo repository will soon be merged back to the main servo repo and these instructions will be amended once that is complete.
Build libsimpleservo2 from source:
git clone --branch phil-ss2-headless https://github.com/philip-lamb/servo.git
cd servo
./mach bootstrap
./mach build --libsimpleservo2
The release libraries will be built by default to path target/release
.The macOS Xcode project for the plugin is at src/ServoUnityPlugin/macOS/servo_unity.xcodeproj
, or the Windows Visual Studio 2019 project is at src/ServoUnityPlugin/Windows/servo_unity.sln
. Compiling the project requires linking to Unity's plugin headers which are normally contained inside the Unity application bundle (macOS) or inside the Unity program directory (Windows). Check that the build setting for header search paths is correct for the version of Unity installed on your system.
On macOS, prior to building, a build step removes any previous plugin build (servounity.bundle
) from the Unity project's Plugins
folder. The Xcode project builds the plugin bundle directly into the same folder. If you wish to change this behaviour, uncheck "deployment postprocessing" in the Xcode build settings.
On macOS, libsimpleservo2 and the required GStreamer plugins will be copied into the servo_unity bundle. On Windows, they will be copied into the same directory as the plugin DLL.
The plugin can run inside the Unity Editor, but the plugin can be run and stopped once per Editor session. (This is due to the fact that Unity does not unload and reload native plugins between runs in the Editor.) You'll need to quit and relaunch the Editor before running again.
To launch with Rust debug logging, use this macOS script (Unity will inherit the environment from Unity Hub):
#!/bin/bash
export RUST_BACKTRACE=1
export RUST_LOG=debug
nohup "/Applications/Unity Hub.app/Contents/MacOS/Unity Hub" &>/dev/null &
The Unity log, including plugin log output, Unity log, and stdout/stderr will be written to either ~/Library/Logs/Unity/Editor.log
or ~/Library/Logs/Mozilla/ServoUnity/Player.log
.