Laser Defender section - Problem with WebGL build and aspect ratio

For the life of me… mirroring the 900x1600 Rick is working on. I have read previous answers including some wonderful ones by Nina that helped me build a WebGL version that works - when running locally alone in a browser window after hitting Build and Run. It works as it tests in the engine. It’s a little to tall vertically for my screen to display all at once but I can change the player size and it stilll tests properly.

But when I attempt to upload to sharemygame.com, even if I try to force the perspective to a 9x16 configuration, it is defaulting to some sort of landscape aspect ratio, where whitespace fills in the sides, and enemies etc are visible outside what is supposed to be the camera view.

Running 2020.3.15f2, which may be part of my issue vs guides I’ve seen maybe? Really proud of the game so far and can’t wait to share it, but I just can’t seem to get it to work on the site. Can anyone help? I have my canvases anchored where they need to be, screen match mode = Match width or height, pinned to the height. Game window is set to the correct aspect ratio (9x16/900x1600). I had seen something about Disable resolution dialogue, but that doesn’t appear anywhere I can see in my build settings. Thanks for reading and if you can help, it is deeply appreciated.

Hi,

Do you have a link to your uploaded game?

900 x 1600 seems to be really large. I would not be able to play this game on my 1920 x 1200 screen. Also, if you press “Fullscreen” on sharemygame.com, the bars appear at the side because the game window will adjust itself to the container on the website.

The resolution dialogue was removed in one of the past versions of Unity, and it does not work for the WebGL build anyway.

I didn’t want to leave a broken game up, so I deleted it, but I can re-upload this afternoon when I get home from work. Would it help to create a Development build?

I agree that the size is generally too large, and I will adjust it. I’m adjusting the player build, the game screen, and the canvas - is there anything else I am missing in that effort?

You really are the best Nina, I appreciate it.

Did you set the resolution correctly in File > Build Settings > Player Settings? The game window does not have anything to do with the build and does not affect it.

Also try to delete the PlayerPrefs. I currently don’t have Unity running but I think I saw that option in the top menu. If there is no such option, create a new script, attach it to a game object. In Awake, you clear the PlayerPrefs. See here. Start your game, then stop it. Build your game, and check if the issue is solved. You may remove the script afterwards.

If the issue persists, maybe you could follow Rob’s instruction in this thread. If you are lucky, there is a helpful error message in your browser console.

I did set them in the build settings/player settings… I think. 99% sure - I will double check later but I believe they did match what I had, whether I was testing in 900x1600 or for example a 675 x 960.

I will look at the other two suggestions and then report back. I’m reading about PlayerPrefs and it seems to be a registry entry, correct?

That’s correct. Sometimes, they also store the resolution, and in that case, the values in the Player Settings suddenly don’t get applied to the build anymore. At least, this was a problem in past versions of Unity.

So many many thanks. It works now. I’m honestly not 100% sure what made it work, as I went back during the adjustment of the resolution and rebuilt a lot at once. But my best guess is that one of the canvases did not match its prefab. I kept getting a bold-text indicator in the inspector that said it was different, though the values in that component were the same. Strange.

But anyway, thank you again so much Nina, it’s deeply appreciated.

Game now active here: https://sharemygame.com/@B17/exterminator-slater

Good job on fixing your game! :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms