Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by LilGames · Apr 20, 2017 at 03:14 AM · webglfullscreenorthographic camera

How do I get black bars top and bottom in webGL fullscreen ?

TL;DR version: I want fullscreen mode in webGL on a 4:3 monitor to NOT CROP the sides of the game, but instead put black bars top and bottom.

Longer post: My project's main size is 1620 x 1080 and I export to webGL.

The webGL default size is set to be a smaller window in the web page, 1024 x 633.

Camera is orthographic. Size 5.4. View rect x0, y0, w1.1, h1

When I go to FullScreen mode (using the default template's button below the game window) if I am on a 1920 x 1080 monitor, the game displays maximized to the height of the screen, and there are black bars on the left and right. This is OK. I want this to happen.

Now the problem: When I test on my 4:3 monitor which is 1280 x 1024 and go full screen, the game maximizes height to 1024, and the width is then CROPPED out, so parts of the game are not visible.

In both examples, the screen height appears to be what the game uses. I want the the screen WIDTH to be used, so that there are black bars above and below the game on the 4:3 monitor, instead of cropping. It should never crop!

In summary, the game is scaling based on HEIGHT rather than WIDTH. Is there a simple way to edit this fullscreen behaviour? Is there somewhere I can set "use width" instead of "use height"?

I've seen some out-dated hacks on controlling the camera aspect ratio, but I'm not sure that's the solution.

Comment
Add comment · Show 1
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 LilGames · Apr 20, 2017 at 02:12 PM 0
Share

TL;DR version: I want fullscreen mode in webGL on a 4:3 monitor to NOT CROP the sides of the game, but ins$$anonymous$$d put black bars top and bottom. On a 16:9 monitor, it is already correctly putting black bars on the left and right by default. The issue is that the game is scaling based on HEIGHT rather than WIDTH.

1 Reply

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

Answer by LilGames · Jul 24, 2017 at 06:11 PM

The solution is to detect that fullscreen mode has been activated, and then resize the camera to fit the width rather than height, based on aspect ratio.

Detect fullscreen, then call your method for setting a new camera size:

     void Update()
             {
                 if(Screen.fullScreen != lastFullscreenState)
                     SetNewSize();
             }

 
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

101 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 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 automaticly goes fullscreen on first click 1 Answer

Canvas behaves differently on PC fullscreen and WebGL fullscreen 0 Answers

Disable fullscreen for webgl 4 Answers

Multi monitor full screen displays 1 Answer

Android 8.0 Crash "Only fullscreen opaque activities can request orientation" 2 Answers


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