Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Setting correct screen resolution / pixel density for WebGL builds

Discussion in '2D' started by chasethomas, Jun 27, 2017.

  1. chasethomas

    chasethomas

    Joined:
    Oct 16, 2015
    Posts:
    17
    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
     
  2. chasethomas

    chasethomas

    Joined:
    Oct 16, 2015
    Posts:
    17
  3. chasethomas

    chasethomas

    Joined:
    Oct 16, 2015
    Posts:
    17
    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.

    Code (CSharp):
    1.         Camera cam = this.GetComponent<Camera> ();
    2.         Debug.Log ("width = " + cam.pixelWidth + " height = " + cam.pixelHeight);
    3.  
     
  4. chasethomas

    chasethomas

    Joined:
    Oct 16, 2015
    Posts:
    17
    Any thoughts on this?