The 'unity webgl not supported on mobile' error typically occurs because the Unity WebGL build is not officially supported on mobile browsers. Unity Technologies states that its WebGL platform is primarily aimed at desktop browsers due to reasons related to performance and compatibility. Mobile browsers often lack the computational power to effectively render the heavy graphics of a Unity WebGL project, which can lead to subpar performance, crashes, or simply being unsupported. Furthermore, some mobile browsers might not fully support all WebGL features, creating additional compatibility issues.
While it's not recommended to run Unity WebGL projects on mobile browsers due to the stated limitations, if you still want to attempt this, there are a few strategies you could consider:
Optimization: Make your game as lightweight as possible. Reduce the number of polygons in meshes, optimize textures, limit the number of active objects and scripts, and use low-poly models when possible.
Check Compatibility: Make sure to test your project across different devices and browsers to ensure it works as expected, and gracefully handle any unsupported features.
Fallback Options: If your application detects a mobile device, provide an alternative experience or notify the user that their device may not be fully supported. You can do this by implementing a warning message or redirecting users to a mobile version of your content (if available).
Consider Using Unity's Project Tiny: Unity's Project Tiny is a new modular Unity runtime and Editor mode designed to build lightweight, fast, and small sized projects. It offers promising outcomes for developing for platforms with limited resources, such as mobile browsers.
In conclusion, while it's technically possible to run Unity WebGL on some mobile devices, it's generally not recommended due to performance and compatibility issues. For best results, consider alternative deployment options for mobile users.