Skip to content

Build And Run Guide

Rick Cheng edited this page Jul 20, 2022 · 2 revisions

Agora WebGL Build And Run Guide

  1. Open the Unity project.
  2. If platform is not set to WebGL, switch platform to WebGL

webgl platform

  1. Open PlayerSettings > Player > Resolution and Presentation.
    If the Unity version is one of the following 2017, 2018 and 2019, select AgoraTemplate agora template

If the Unity version is 2020 or above then AgoraTemplate2020 needs to be selected. Note only LTS are verified for each release. There is no guarantee that the SDK runs on alpha versions of Unity.

agora template 2020

  1. Start the build process using Build and Run. Note that Unity built-in server works on 2020, but doesn’t seem to work on 2017. Please see the Tips section.

webgl build

  1. If the build is successful, the console should have no errors.

built resuit

Your WebGL project should be running on the default Web browser. We highly encourage the use of Google Chrome as the browser.

Tips on running WebGL project

  1. In case of your Web Browser fails to connect to Unity generated server:

problem1 You can run a local server at the build directory manually. For example,

php -S localhost:3000

or

python -m SimpleHTTPServer 3000

Then run the application from http://localhost:3000

  1. If you use AgoraTemplate while your Editor is version 2020/2021/2022, you will see a white page displaying no WebGL canvas. Use AgoraTemplate2020 instead.

  2. If you see an error message about undefined _createRtcEngine, then you failed to provide a valid template for running WebGL, remember to select AgoraTemplate or AgoraTemplate2020:
    problem2

  3. On Unity 2020 or above, if the build doesn’t start on Chrome, you may see this JS Console log message:

zip issue

Fix it by disabling the compression format in Publishing Settings.

disable zip

  1. Unity SDK 2021 (and some later versions): there is a new emscripten STRICT mode introduced, and it affects symbol checking, and also disables auto-includes of js libraries. Fix this problem by adding “-s ERROR_ON_UNDEFINED_SYMBOLS=0 “ to WebGLEmscriptenArgs: in
    ProjectSettings\ProjectSettings.asset.

  2. Compilation error about “UnityHook” undefined: this could be due to an upgrade of the SDK affecting the cache in your project. Make sure you clean your Unity project completely and import the SDK again.


Clone this wiki locally