better-unity-webgl-template icon indicating copy to clipboard operation
better-unity-webgl-template copied to clipboard

How to set a maximum size limit?

Open saadjumani opened this issue 4 years ago • 1 comments

I want my game to be responsive if browser window is smaller than a specific size (960 px width). But stay the same size if window is larger. How do I go about doing that?

saadjumani avatar Oct 18 '20 02:10 saadjumani

You could try editing Assets/WebGLTemplates/Better2020/TemplateData/style.css

Add these lines

#unity-container {
    width: 100%;
    height: 100%;
    display: flex;           /* added */
    justify-content: center; /* added */
    align-items: center;     /* added */
}
#unity-canvas {
    width: 100%;
    height: 100%;
    max-width: 960px;   /* added */
    max-height: 540px;  /* added */
    background: {{{ BACKGROUND_COLOR }}};
}

greggman avatar Oct 18 '20 03:10 greggman