Search Unity

Make canvas aspect ratio change according to browser resize?

Discussion in '2D' started by ccurry_unity, Mar 23, 2018.

  1. ccurry_unity

    ccurry_unity

    Joined:
    Nov 2, 2017
    Posts:
    28
    Hello!

    I have a WebGL game that is set to take up 100% of the browser space. I've set the canvas scaler to "scale with screen size", so that when the player resizes the browser, the UI elements will scale / position accordingly.

    However, when the unity canvas scales it maintains its aspect ratio (essentially 16:9), so that if the browser ends up in a square, the UI elements are sort of in the top middle of the game.

    Is it possible to have your canvas aspect ratio be fluid? (Currently using the reference resolution of 960px x 602 px). This way, my UI elements could position to the top left and top right of the window, even if the player made the window 300px x 1000px

    Thanks!