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
1
Question by Danielfc · Apr 08, 2019 at 06:19 AM · unity5macosxfullscreenresolution settings

Avoiding The Black Bars (LetterBoxing)

We have upgraded our project from Unity 2017.4.4f1 to 2018.3.11f1,

When building for a Mac we notice a different result which we want to know how to avoid, we set our app to Windowed and it is opening in a windowed mode as required, but when we maximize the window (using the window maximize button) there are black bars on top and on the bottom which is also known as letterboxing and obviously not everyone would want their app to be in this style.

Would appreciate some information on why they appear while on 2017.4.4f1 it didn't happen.

Except the removal of "Mac Fullscreen Mode" and "D3D11 Fullscreen Mode" in PlayerSettings -> Resolution and Presentation window since they became deprecated nothing has changed in terms of any parameters that were set there.

Thank you in advance.

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

2 Replies

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

Answer by Danielfc · Apr 08, 2019 at 11:22 AM

I have managed to solve my issue, i do not believe its the best solution out there but it does what i wanted it to do.

Basically everything related to the application resolution information is saved by PlayerPrefs with the keys such as :

  • Screenmanager Resolution Width

  • Screenmanager Resolution Height

  • Screenmanager Fullscreen mode

  • Screenmanager Resolution Use Native

By deleting all the keys of screenmanager when quitting the app i managed to give the feeling of every time the user opens the app it will act like it was opened for the first time when it comes to the resolution only.

Which means if somehow something happened with the resolution of the app and something got messed up then that information will not be saved and will be reset once the app is being closed and any other information that is not related to that in the PlayerPrefs will remain such as quality settings and more.

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
0

Answer by SweatyChair · Aug 01, 2019 at 06:01 AM

This is our solution:

  1. Build the game default fullscreen mode

  2. Use this script to:

  • When changing from fullscreen to window mode: set the width to 1920 and height proportional to monitor size ( Screen.currentResolution ), save the ratio in PlayerPrefs.

  • When changing from window to full-screen mode: set the width to 1920 and height proportional to the saved ratio.

The reason we need PlayerPrefs to save the ratio is that Unity cannot obtain the monitor size in full-screen mode. Screen.currentResolution gives the current resolutions (the window size in window mode). There may be an even better solution using Windows.System.Display, but using PlayerPrefs is good enough. Let me know if anyone knows another way to do it.

 using UnityEngine;
 
 namespace SweatyChair
 {
 
     /// <summary>
     /// Remove the letterbox when switching windows mode to full screen mode, set the windows to manual screen width
     /// when switching full screen mode to windows mode. Standalone only.
     /// </summary>
     public class ScreenModeSwitcher : PersistentSingleton<ScreenModeSwitcher>
     {
 
         #if UNITY_STANDALONE
 
         private const string PREFS_LAST_SCREEN_RATIO = "LastScreenRatio";
 
         private bool _fullScreen;
 
         private void Start()
         {
             _fullScreen = Screen.fullScreen;
         }
 
         private void Update()
         {
             if (_fullScreen != Screen.fullScreen) {
                 if (_fullScreen) { // Full screen mode to window mode, simply set resolution with manualScreenWidth
                     Screen.SetResolution(SettingSettings.current.manualScreenWidth, Mathf.RoundToInt(1f * SettingSettings.current.manualScreenWidth * Screen.currentResolution.height / Screen.currentResolution.width), Screen.fullScreen);
                     PlayerPrefs.SetFloat(PREFS_LAST_SCREEN_RATIO, 1f * Screen.currentResolution.width / Screen.currentResolution.height); // Save the screen ratio, so this can be used next time full screen
                 } else {
                     // When in windows mode, both Screen.width/height or Screen.currentResolution are set to the windows size, try get one from saved PlayerPrefs value or default it to 16:9
                     float screenRatio = PlayerPrefs.GetFloat(PREFS_LAST_SCREEN_RATIO, 16f / 9);
                     Screen.SetResolution(SettingSettings.current.manualScreenWidth, Mathf.RoundToInt(1f * SettingSettings.current.manualScreenWidth / screenRatio), Screen.fullScreen);
                 }
                 _fullScreen = Screen.fullScreen;
             }
         }
 
         #endif
 
     }
 
 }

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

169 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 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

unity3d 5 game on fullscreen shows only half of game screen 4 Answers

No readable font with unity 5.3.0 on OSX 10.9.5 6 Answers

Mac : Allow Fullscreen Switch but without command+F 0 Answers

Play sound within limited region 2 Answers

help me please. NullReferenceException: Object reference not set to an instance of an object 0 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