Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Colcoction · Aug 27, 2017 at 06:58 PM · webglhtmlhtml5template

Unwanted empty border in WebGL minimal template

I have been exporting apps to WebGL with the "Minimal" template selected in Player Settings > Resolution and Presentation. When I run these applications in a browser, they seems to take on a slight border of empty space around at least the top and left sides, separating them from the edges of the window they are otherwise drawn to. I first noticed this with the games I uploaded to itch.io, and when I tried opening an exported .html file directly with Firefox, I noticed a similar gap between the game window and the top-left corner of the screen.

What is causing this? Is there any way to remove this empty space?

alt text alt text

attach-1.png (64.0 kB)
attach-2.png (113.8 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by ColinAmosGames · Feb 15, 2018 at 09:08 PM

I believe I've realized where these spaces are coming from: default HTML styling.


From how I understand it, Unity's "Minimal" WebGL template is not just a simply designed template, it's basically no template at all. When a web browser loads the Unity project, it looks for a style guide to tell it how to display the elements on the page. When it finds none, it references it's own style guide (which seems to be fairly standard across the major browsers at this point) by default. It so happens that the typical default style guide currently includes a margin of 8 pixels, and this is basically what causes that buffer around the edges (default top-left alignment also contributes to the problem). It kind of makes sense for totally blank web pages, but it starts to look wonky once it's embedded in a more complex layout like the one that itch.io uses.


So, we can blame Unity for making their "Minimal" template too minimal, itch.io for not implementing robust formatting features, or ourselves for trying to publish games to the Web without knowing a shred of HTML/CSS in the first place.


In any case, the solution I've gone with for now is creating a custom template based on the Default template and just taking out the code and resources for the footer bar. I've attached a .zip with the template I use and instructions for how to use it / add it to Unity.


I hope this helps!


fixed-webgl-template.zip (22.2 kB)
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
4

Answer by Ranom · Aug 28, 2019 at 11:18 AM

Hi All,

I came across the same problem and fixed it in the minimal template:

Modify your index.html as follows:

 <body style='margin: 0px;'>

That's it, enjoy :-)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Waldridge · May 11 at 04:10 PM 0
Share

Thanks, worked great for me!

avatar image
0

Answer by hromoyDron · Feb 15, 2018 at 02:04 PM

same question. what to do? who knows?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

75 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

WebGL Game Window not Aligned with Canvas 1 Answer

Set content of a custom tag of a WebGL template via script 0 Answers

Itch.io webgl not uploading properly 1 Answer

Unity webgl or threejs or babylonjs ? Which one is the best for me? 1 Answer

How do i build a game for webgl and display it in an html document? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges