Setting correct screen resolution / pixel density for WebGL builds

Hi all,

Apologies if this has been posted (did a search and didn’t find exactly what I’m looking for). I’m trying to set up a 2d project to export to WebGL. However, when I build, my UI elements appear stretched. I’m assuming this is because the resolution in the player settings is different than the camera resolution (which I can’t seem to find).

My question is- how do you ensure that what you’re seeing in the unity editor will be mirrored when exported to html?

Additionally, is there a setting for detecting a retina display? I would love to future proof this a bit, if possible.

Thanks in advance!
Chase

Found this great blog post on creating a pixel-perfect game: Unity Blog

Still haven’t solved the issue of my build being a different resolution than what I’m previewing in the GUI.

I added this to my cameraController script, then set the build resolution to the same values, but man there’s gotta be an easier way than this.

        Camera cam = this.GetComponent<Camera> ();
        Debug.Log ("width = " + cam.pixelWidth + " height = " + cam.pixelHeight);

Any thoughts on this?