Version: Unity 6 (6000.0)
LanguageEnglish
  • C#

WasmCodeOptimization

enumeration

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Options for the optimization mode to use for compiling Web code.

This enum provides optimization settings for WebAssembly (Wasm) code in Unity Web builds, enabling developers to balance file size, runtime performance, and build speed depending on their needs.

using UnityEditor;

class WebOptimizer { [MenuItem("Example/Optimize For Disk Size")] static void OptimizeForDiskSize() { #if UNITY_WEBGL // Set code optimization setting to optimize for disk size UnityEditor.WebGL.UserBuildSettings.codeOptimization = UnityEditor.WebGL.WasmCodeOptimization.DiskSize; // You will find the setting applied now in File > Build Settings > Web > Web Settings #endif } }

Properties

Description
RuntimeSpeedGenerate Web code that’s optimized for runtime performance, at the expense of taking a longer time to build compared to WasmCodeOptimization.BuildTimes.
RuntimeSpeedLTOGenerate Web code that’s optimized for runtime performance, at the expense of taking a longer time to build compared to WasmCodeOptimization.BuildTimes. Also enable an additional Link Time Optimizations (LTO) stage.
DiskSizeFavor optimizations that minimize build size, at the expense of taking a longer time to build compared to WasmCodeOptimization.BuildTimes.
DiskSizeLTOFavor optimizations that minimize build size, at the expense of taking a longer time to build compared to WasmCodeOptimization.BuildTimes. Also enable an additional Link Time Optimizations (LTO) stage.
BuildTimesGenerate Web code that takes the least amount of time to build.