Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

451
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda