-
Notifications
You must be signed in to change notification settings - Fork 25
Build And Run Guide
Agora WebGL Build And Run Guide
- Open the Unity project.
- If platform is not set to WebGL, switch platform to WebGL
- Open PlayerSettings > Player > Resolution and Presentation.
If the Unity version is one of the following 2017, 2018 and 2019, select AgoraTemplate
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.
- 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.
- If the build is successful, the console should have no errors.
Your WebGL project should be running on the default Web browser. We highly encourage the use of Google Chrome as the browser.
- In case of your Web Browser fails to connect to Unity generated server:
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
-
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.
-
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:
-
On Unity 2020 or above, if the build doesn’t start on Chrome, you may see this JS Console log message:
Fix it by disabling the compression format in Publishing Settings.
-
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. -
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.