Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

446
Views
Portrait mode shows black screen on a browser in Unity Webgl, landscape opens fine

I am using Unity version 2019.4.19f1 to make webgl build. After making the build I resize the unity canvas using these line below (in UnityLoader.js inside "DOMContentLoaded" eventlistner):

let unityContent = document.getElementById('unityContainer');
var tempWidth = window.innerWidth - ( window.innerWidth * 0.0001 );
var tempHeight = window.innerHeight;
unityContent.style.width = tempWidth+'px';
unityContent.style.height = tempHeight+'px';

But when I open this in a browser in Portrait mode I get a black screen, while when I open it in landscape mode then it is working fine. And this happens in devices having screen size 6 inches and above only. On devices having smaller height the portrait mode opens fine and no black screen is shown.

Also if I hard code the tempHeight to 1500px then even portrait mode shows the canvas instead of black screen but then there is empty space on the screen above and below the canvas. What's more troubling is that the same code was working fine a few months ago in other projects.

Can Anyone Help me out with this please? Have been stuck on this for some time now.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Have you just tried setting the width and height to a 100% of screen and are able to reproduce the issue?

If it works with this, then your canvas is getting drawn outside the bounds, else there's something else wrong.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!