WebGL
When building for WebGL, Unity will strip some shaders that would otherwise be included on other platforms. This causes the FadeEffect shader used by the teleport transition to be excluded from the project.
[Error] ArgumentException: Invalid shader ()
at UnityEngine.Rendering.PostProcessing.PropertySheetFactory.Get (UnityEngine.Shader shader) [0x00000] in <00000000000000000000000000000000>:0
To fix this, you can add the FadeEffect shader to the Always Included Shaders list in Unity’s Graphics settings.
In ’newer’ versions of Unity, the ability to switch the WebGL linker target has been removed. This means that when updating asm.js projects (from an older version from Unity) you are not able to switch to WebAssembly.
Below is a script that can be placed in an Editor folder in your project that will display a prompt that allows you to switch.
using UnityEditor;
using UnityEngine;
/// <summary>
/// Utility to update WebGL linker target to use WebAssembly in newer versions of Unity where the option has been hidden
/// </summary>
public static class WebGLUpdater
{
/// <summary>
/// Check now
/// </summary>
[InitializeOnLoadMethod]
private static void Execute()
{
if (PlayerSettings.WebGL.linkerTarget != WebGLLinkerTarget.Asm || Ignore)
{
// Linker target is already correct or utility has been ignored
return;
}
// Display message box
const string title = "WebGL Updater";
var message =
$"The WebGL linker target for this project is currently set to {PlayerSettings.WebGL.linkerTarget}.\n\nWould you like to switch to {WebGLLinkerTarget.Wasm} now?";
var apply = EditorUtility.DisplayDialog(title, message, "Yes", "Ignore");
// Update or ignore
if (apply)
{
PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Wasm;
Debug.LogFormat("WebGL Linker Target is set to: {0}", PlayerSettings.WebGL.linkerTarget);
}
else
{
Ignore = true;
}
}
/// <summary>
/// If the check has been ignored
/// </summary>
/// <remarks>Value resets when closing the Unity Editor</remarks>
private static bool Ignore
{
get => SessionState.GetBool($"{nameof(WebGLUpdater)}.{nameof(Ignore)}", false);
set => SessionState.SetBool($"{nameof(WebGLUpdater)}.{nameof(Ignore)}", value);
}
}
When installing the Platform Services 1.2 package, there is a compilation error that will appear in the console.
Microsoft (R) Visual C# Compiler version 3.5.0-dev-20359-01 (8da8ba0c)
Copyright (C) Microsoft Corporation. All rights reserved.
error CS0006: Metadata file
'.../Library/PackageCache/io.immerse.platform.services@1.1.0/Runtime/Multiuser/Client/Standalone/websocket-sharp-immerse.dll' could not be found
To fix this, you can uninstall a different package in your project and then re-install it again.