Different fill mode for desktop

Is it possible to have the fill mode “Keep aspect ratio” for desktop and “Fill window” for mobile devices?

Yes its possible,

 setFillMode() {

thanks for answering! … but where I should place and call that function? I’m using the editor

Call it in the initialize function of any script.

I will add an answer here, instead of Discord:

As @Saad_Haider mentioned you should add it in the initialize() method. For example:

Script.attributes.initialize = function() {
Script.attributes.setFillMode = function() {
    if (pc.platform.mobile) {
1 Like


I was getting a black stripe above

I fixed that adding those lines:

if(pc.platform.mobile) {
          document.getElementById("application-canvas").style.height = "100%";
          document.getElementById("application-canvas").style.margin = 0;

I’m wondering if script initialise is too late and perhaps adding it the loading script is better or even earlier?

no, same problem if I do it in the preload script

Hi there! Has anyone found the solution for that black bar issue? I am getting the same problem

@Cheburashka Please see this thread: [SOLVED] Trying to switch between Fill Mode to Keep Aspect ratio