Legacy project failing to generate the correct WebGL build files

I have a legacy project that has been updated to Unity 2020.1.0f1 and I’m able to create a PC/Mac standalone build successfully.

But, if I try to create a WebGL build, Unity is generating the old “.asm” version of the files: (WebGL.asm.framework.js, WebGL.asm.js, WebGL.asm.loader.js, WebGL.asm.mem, WebGL.data).

But it should be generating the newer “.wasm” files: (WebGL.framework.js, WebGL.loader.js, WebGL.wasm, WebGL.data). Which it does, if a create a 3D project from scratch with this Unity version.

Is there a solution to this problem?

You can change this via scripting Unity - Scripting API: PlayerSettings.WebGL.linkerTarget

Which will allow you to specify it as wasm.

Thanks for your help. But I’m still having trouble actually implementing the suggested code. Here’s mine that I have on an empty game object:

using UnityEditor;
using UnityEngine;

public class WebGLLinkTarget : MonoBehaviour
{
public static WebGLLinkerTarget linkerTarget;

void Start()
{
linkerTarget = WebGLLinkerTarget.Wasm;
}
}

The script compiles OK when I return to the Editor, but the WebGL build crashes immediately.

The error message is: The type or namespace name ‘WebGLLinkerTarget’ could not be found (are you missing a using directive or an assembly reference?)

Thanks again for your help.

No its an editor setting, create an editor menu option to run this from.

Use that and remove the start method entirely, and do not make this a monobehaviour make it a normal class.

Your issue is you are trying to run editor code as if it is runtime code :slight_smile:

1 Like