WebGL Support

Overview

The Motive SDK supports WebGL builds in Unity. To use WebGL, use the WebGL Player prefab. WebGL Player uses standard mouse and keyboard input instead of XR controllers.

SDK version 2.1 is recommended for WebGL support.

Configuration

WebGL Player is a drop-in replacement for Open XR or XR Toolkit player. Use https://motiveio.atlassian.net/wiki/spaces/USDK/pages/1408958467 to configure your project to support multiple platforms.

Local Development

Unity Editor

WebGL controls and input can be tested directly in the Unity editor. Use Unity testing to make sure authoring and configured components work as expected.

Local Web Server

Once you have verified that the app works in Unity, it can be exported to as a WebGL app. Unity offers both Build and Build and Run options. Build and Run starts a lightweight web service and opens the app in a web browser. This will likely result in errors trying to access the content due to security restrictions. This is our recommended approach to work around these issues. Note that these security issues will not appear when the app is deployed to Launch as described below.

  1. Create a runweb.cmd command file and with the following line. Note that the Unity version should align with a version installed on your system.

    "C:\Program Files\Unity\Hub\Editor\2020.3.40f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\SimpleWebServer.exe" %1 8000
  2. Run the webserver and point it at the folder with the web build. This will start the server on port 8000 (or whatever port you assigned in the command above).

    > runweb.cmd Builds/WebBuild
  3. Now launch a browser with security features disabled. For example, the following command launches Chrome with CORS and other security disabled so that the calls to the service will work. By default, the browser will not make connections or send authentication cookies to an unknown URL. Note that the directory specified in “user-data-dir” must exist on your system, or this call will fail.

    "C:\Program Files\Google\Chrome\Application\chrome.exe" --disable-web-security --user-data-dir=C:\chromeTemp
  4. You should be able to launch the web build in this browser by connecting to localhost:8000. Log into Storyflow in another tab in this browser to get the correct cookies on your system.

Additional Launch Arguments

You can tweak how the content launches with additional launch arguments on the URL. These values will override any values in the App Config.

Parameter

Value

Parameter

Value

launchMethod

storyflow or launch

motiveCloudUrl

URL to use to access Motive Cloud

Examples

Launch in Storyflow author mode, bypassing device code input. This requires that you are logged into Storyflow in the same browser.

Change the base URL for Motive Cloud to use ca-east-a:

Deploying to Launch

WebGL builds can be uploaded to Launch in the WebGL tab. You will point the upload to the base directory of your web build. Once uploaded, you can add WebGL builds to Modules so that they can be launched with a Launch Code.

Related Articles

Building and Hosting Unity WebGL Applications on Launch

Troubleshooting WebGL