Skip to content

Commit

Permalink
BuildWebGL updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ScvirelVS committed May 18, 2022
1 parent 3c26915 commit 13fc526
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions Editor/Platforms/WebGL/BuildWebGL.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
#if UNITY_WEBGL

using System.Threading.Tasks;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEditor.WebGL;
using UnityEngine;

#if UNITY_WEBGL
using UnityEditor.WebGL;
#endif

namespace UniTools.Build
{
#if UNITY_WEBGL

[CreateAssetMenu(
fileName = nameof(BuildWebGL),
menuName = MenuPaths.WebGL + nameof(BuildWebGL)
)]
public sealed class BuildWebGL : ScriptableBuildStepWithOptions
{
#if UNITY_WEBGL
[SerializeField] private CodeOptimization m_codeOptimization = CodeOptimization.Size;
#endif
[SerializeField] private Il2CppCodeGeneration m_IL2CPPCodeGeneration = Il2CppCodeGeneration.OptimizeSize;
[SerializeField] private WebGLExceptionSupport m_exceptionSupport = WebGLExceptionSupport.None;
[SerializeField] private WebGLCompressionFormat m_compressionFormat = default;
Expand All @@ -41,8 +39,11 @@ public override async Task<BuildReport> Execute()
PlayerSettings.WebGL.dataCaching = m_dataCaching;
PlayerSettings.WebGL.debugSymbolMode = m_debugSymbolMode;
PlayerSettings.WebGL.decompressionFallback = m_decompressionFallback;

EditorUserBuildSettings.SetPlatformSettings(UnityEditor.BuildPipeline.GetBuildTargetName(BuildTarget.WebGL), "CodeOptimization", m_codeOptimization.ToString()); // or "size"
#if UNITY_WEBGL
EditorUserBuildSettings.SetPlatformSettings(UnityEditor.BuildPipeline.GetBuildTargetName(BuildTarget.WebGL), "CodeOptimization", m_codeOptimization.ToString());
#else
EditorUserBuildSettings.SetPlatformSettings(UnityEditor.BuildPipeline.GetBuildTargetName(BuildTarget.WebGL), "CodeOptimization", "Size");
#endif
EditorUserBuildSettings.il2CppCodeGeneration = m_IL2CPPCodeGeneration;

AssetDatabase.Refresh();
Expand All @@ -57,4 +58,4 @@ public override async Task<BuildReport> Execute()
}

#endif
}
}

0 comments on commit 13fc526

Please sign in to comment.