greggman / better-unity-webgl-template

A better default template for Unity WebGL
https://greggman.github.io/better-unity-webgl-template/
Creative Commons Zero v1.0 Universal
753 stars 136 forks source link

Can you choose a resolution lower than the screen's actual resolution? #27

Open Roozbehmd opened 1 year ago

Roozbehmd commented 1 year ago

Fantastic work on the template. Only issue is that when viewed on high resolution screens it requires a lot of resources to run smoothly. Any way to lower the resolution and then upscale to fullscreen?

greggman commented 1 year ago

You can try editing

Assets/WebGLTemplates/Better2020index.html

around line 30 add

        devicePixelRatio: 1,

as in

      const config = {
        devicePixelRatio: 1,  // <=---------  ADDED!
        dataUrl: buildUrl + "/{{{ DATA_FILENAME }}}",
        frameworkUrl: buildUrl + "/{{{ FRAMEWORK_FILENAME }}}",
        codeUrl: buildUrl + "/{{{ CODE_FILENAME }}}",
#if MEMORY_FILENAME
        memoryUrl: buildUrl + "/{{{ MEMORY_FILENAME }}}",
#endif
#if SYMBOLS_FILENAME
        symbolsUrl: buildUrl + "/{{{ SYMBOLS_FILENAME }}}",
#endif
        streamingAssetsUrl: "StreamingAssets",
        companyName: "{{{ COMPANY_NAME }}}",
        productName: "{{{ PRODUCT_NAME }}}",
        productVersion: "{{{ PRODUCT_VERSION }}}",
      };

you might be able to set it to 0.5 for even lower res.

Note: I didn't try it but it's mentioned here:

https://docs.unity3d.com/Manual/webgl-canvas-size.html

Roozbehmd commented 1 year ago

Thank you!