Version: 2022.3
Language : English
Create callbacks between Unity C#, JavaScript, and C/C++/C# code
WebGL native plug-ins for Emscripten

Replace deprecated browser interaction code

Some of the code involved with web browser script interactions is deprecated and has been replaced with alternative code.

If your code contains any of the deprecated code, you need to update the code with the replacement code to prevent unexpected behavior or broken code.

Deprecated code quick reference

The following code is deprecated and you need to replace it with the replacement code.

Deprecated code Replacement code
dynCall() makeDynCall()
Pointer_stringify() UTF8ToString()
unity.Instance() CreateUnityInstance()
gameInstance unityInstance

Change dynCall to makeDynCall

The dynCall function is deprecated. If you have any code that uses dynCall, replace it with makeDynCall. Make this change whether you have WebAssembly.Table enabled or not.

For example, change:

dynCall('vii', callback, [1, 2])

to:

{{{ makeDynCall('vii', 'callback') }}}(1, 2)

Change Pointer_stringify() to UTF8ToString

The Pointer_stringify() function is deprecated. If your code contains calls to Pointer_stringify(), replace the calls with UTF8ToString().

For example, change:

var stringMessage = Pointer_stringify(message);

to:

var stringMessage = UTF8ToString(message);

Change unity.Instance to CreateUnityInstance

unity.Instance is deprecated. If your code uses unity.Instance, use CreateUnityInstance instead.

For example, change:

var MyGameInstance = null;
  script.onload = () => {
    unity.Instance(canvas, config, (progress) => { /*...*/ }).then((unityInstance) => {

to: js var MyGameInstance = null; script.onload = () => { createUnityInstance(canvas, config, (progress) => { /*...*/ }).then((unityInstance) => {

Change gameInstance to unityInstance

The gameInstance property is deprecated. If your code uses gameInstance, use unityInstance instead.

For example, change:

MyGameInstance = gameInstance;

to:

MyGameInstance = unityInstance;

Additional resources

Create callbacks between Unity C#, JavaScript, and C/C++/C# code
WebGL native plug-ins for Emscripten
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961