I developed a WebGL Unity 3D app with a 3d character that can navigate in the environment (mouse navigation and WASD) and interact with some objects. On windows it is all great and the FPS is 45-60 and the resolution is 1920 * 1xxx. On Macs the performance drops to 13-17 because of Retina and the resolution is 3300 * 2100 (double the laptop's resolution). How can I handle this ? Any help would be appreciated.Thanks in advance!
Unity WebGL performance issues on Retina (MacBook)
2.7k Views Asked by Siba Mahlouby AtThere are 4 best solutions below
On
In Unity if you go to Edit menu > Project settings > Player | Resolution and Presentation : Display Resolution Dialog. You can change the default settings for your program.
Here you can see the default ratio's your screen will be displayed in
This is a course on unity's performance optimization
For more information go to link
Or the Unity Desrciption itself.
On
Okay so if you go into webGL, in unity itself. so: WebGL > WebGL Player Settings > Resolution and Presentation.
you will find this screen.
Setting Function
Default Canvas Width
Set the width of the WebGL canvas element.
Default Canvas Height
Set the height of the WebGL canvas element.
Run In Background
Enable this option to allow your content to continue to run when the canvas or the browser window loses focus.
On
Thank you Siba for your hint. Though I had to search a bit how to actually do it for 2019.4.
Just in case anyone stumbles upon this, I did this in JavaScript, right before UnityLoader.instantiate:
window.devicePixelRatio = 1;
If you're using newer Unity versions, this thread might also help: https://forum.unity.com/threads/webgl-retina-scaling.853144/
I needed to add a JavaScript code to the html file to set the DPI to 1