Issues
This page contains issues that you may encounter in Unity WebGL games, and potential fixes to them.
MacOS rendering issues
If you are using URP, you may encounter rendering issues on Mac (black meshes, or flickering meshes).
A potential fix is to disable Depth Priming Mode in Universal Renderer Data.
WebGL random abnormal high values in mouse input
We have encountered some games randomly registering an abnormally high mouse input when reading the mouse movement. If your game is also affected by this issue, you can use the following script:
using UnityEngine;
public class MouseInput : MonoBehaviour
{
private const float threshold = 100f;
private float prevDeltaX = 0f;
private float prevDeltaY = 0f;
private float filteredDeltaX = 0f;
private float filteredDeltaY = 0f;
void Update()
{
float currentDeltaX = Input.GetAxisRaw("Mouse X");
float currentDeltaY = Input.GetAxisRaw("Mouse Y");
filteredDeltaX = AvoidFlicks(currentDeltaX, ref prevDeltaX);
filteredDeltaY = AvoidFlicks(currentDeltaY, ref prevDeltaY);
}
private float AvoidFlicks(float currentDelta, ref float prevDelta)
{
if (Mathf.Abs(currentDelta - prevDelta) > threshold)
{
return prevDelta;
}
prevDelta = currentDelta;
return currentDelta;
}
public float GetDeltaX()
{
return filteredDeltaX;
}
public float GetDeltaY()
{
return filteredDeltaY;
}
}
Attach it to an object in your scene, and obtain the mouse input via the GetDeltaX
or GetDeltaY
methods.