How to generate a .wasm file when building

Thought this would be a simple question but I’ve searched everywhere, save for posting here.

Anywho, trying to upload my game to Simmer.io, which requires a wasm file for uploading except no matter how I configure the build settings in Unity, I end up without a wasm file (I DO get a .asm file, however).

I’ve tried this with Unity 2020 1.3f1 and the latest version of Unity, and I have no idea what’s happening. In player settings, I did notice that I’m building based on WebGL 2.0 graphics API. I’ve searched around and can’t seem to figure this one out.

Heres the build output:

Here are my player settings:




Hoping someone can help, thanks!

This is an example on how you can achieve it.

  • Create a folder “editor” in your assets folder
  • Create a C# script called WebAssemblyOption in the editor folder.
    Past this inside :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class WebAssemblyOption
{
    [MenuItem("Web Assembly/Enable Threads Support")]
    static void EnableThreads()
    {
        PlayerSettings.WebGL.threadsSupport = true;
        ToggleActionValidate();
    }

    [MenuItem("Web Assembly/Disable Threads Support")]
    static void DisableThreads()
    {
        PlayerSettings.WebGL.threadsSupport = false;
        ToggleActionValidate();
    }

    [MenuItem("Web Assembly/Enable Wasm Only")]
    static void EnableWasm()
    {
        PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Wasm;
        WasmActionValidate();
    }

    [MenuItem("Web Assembly/Disable Wasm Only")]
    static void DisableWasm()
    {
        PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Both;
        WasmActionValidate();
    }

    [MenuItem("Web Assembly/Threads Support Active", false)]
    public static bool ToggleActionValidate()
    {
        Menu.SetChecked("Web Assembly/Threads Support Active", PlayerSettings.WebGL.threadsSupport);
        return true;
    }

    [MenuItem("Web Assembly/Wasm Only", false)]
    public static bool WasmActionValidate()
    {
        Menu.SetChecked("Web Assembly/Wasm Only", PlayerSettings.WebGL.linkerTarget == WebGLLinkerTarget.Wasm?true:false);
        return true;
    }

}

Compile and you will have a new menu in your unity called “Web Assembly” (where you have file,edit,assets ect …)
Click “Web Assembly/Disable Wasm Only” == > compile and you will have both .asm and .wasm

I have tried this and I get the following error:

Assets\Editor\WebAssemblyOption.cs(32,45): error CS0619: ‘WebGLLinkerTarget.Both’ is obsolete: ‘WebGLLinkerTarget.Both mode is no longer supported. Instead you can create separate asm.js and WebAssembly builds and download the appropriate one depending on the browser capabilities.’

You can force Unity to build both by editing this line in ProjectSettings.asset file in your Project/ProjectSettings folder:
webGLLinkerTarget: 2
0 = asm.js
1 = Wasm
2 = both

P.S. I am not sure, that it is still possible for Unity 2021+, because asm.js is deprecated from this version of Unity.

1 Like