• 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
0
Question by Triss211 · Oct 03, 2015 at 10:57 AM · resolutionwindowsstandalonefullscreen

SetResolution in full screen is a nightmare (Standalone Windows)

Hey

I wanted to allow the user to change the resolution of my standalone WIndows application in game . It does seems quite simple, but in fact resolution change works extremely badly in fullscreen mode. Here are the different solutions I tried :

  • D3D11 Fullscreen mode : Fullscreen Window => Changing resolution by using Screen.SetResolution resolution works... But if the resolution is not the maximum resolution handled by the screen then there are black strips on the borders instead of upscaling to the screensize. Moreover the UI detects events at bad positions. Also, performances are worse than in Exclusive mode.

  • D3D11 Fullscreen mode : Exclusive => At least the game run in a true full screen mode. Yes it does crash if you use Alt tab but I don't find this behavior really dramatic. BUT changing resolution often makes the game crash. And I found no way to define a start resolution by script... The game launch at its default resolution and then, even putting it in awake, the SetResolution function is called and eventually makes the game crash. By crash I mean a black screen. I tried to switch from windowed mode to fullscreen when changing the resolution but it doesn't keep the game from crashing.

  • OpenGLCore instead of direct3D : The game crashes deadly ("ERROR: Error while initializing dbghelp.dll, GetLastError: 'L’opération a réussi.' (Address: 00000000)") immediately in full screen for a lot of different resolution which are supposed to be supported...

So the only way I see it working is by keeping the default launcher to allow the user to choose the resolution... Did I miss something or Unity really doesn't handle well at all resolution changing in full screen mode on Windows ? This behavior happened in both Windows 10 and Windows 8.1. I didn't try D3D9 but I really don't want to use it.

Sincerely, Léo.

[UPDATE] It seems to be possible to define the game resolution by sending command line arguments as it's described here : http://docs.unity3d.com/Manual/CommandLineArguments.html I think I'm going to create a custom launcher doing that. Or maybe make my game restart to apply a resolution change.

Comment
Add comment · Show 3
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 Suddoha · Oct 03, 2015 at 11:04 AM 0
Share

Are you using Unity 5.2? When I upgraded to it the problem appeared, it worked well in earlier versions though. People have already filed bug reports as far as i know.

avatar image Triss211 Suddoha · Oct 03, 2015 at 11:32 AM 1
Share

Yes I'm using Unity 5.2. Thank you for your answer, let's wait for a bug correction in the next version...

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Triss211 · Oct 03, 2015 at 11:40 AM

So apparently this is a Unity 5.2 bug... Anyway I worked around the problem by restarting the application to change the resolution with this coroutine I wrote :

   public  IEnumerator coroutResolution()
     {
         //get the toggle full screen value
             m_newFullScreen = m_toggleFullScreen.isOn ? 1 : 0;
 
         //Go to windowed mode because if you restart the game from full screen in exclusive mode it sometimes keep the same aspect ratio..
         // Set to the new resolution because it will kept this resolution when restarting
             Screen.SetResolution(m_resolutions[m_ddResol.value].width, m_resolutions[m_ddResol.value].height, false);
             yield return new WaitForEndOfFrame();
 
         //We get the executable location
             string[] s = System.Reflection.Assembly.GetExecutingAssembly().Location.Split('\\');
             StringBuilder location = new StringBuilder();
             for (int i = 0; i < s.Length - 3; i++)
             {
                 location.Append(s[i] + '\\');
             }
             location.Append(m_exeName);
             string exe = location.ToString();
 
         //Start the new process with only the fullscreen parameter, height and width being kept if the resolution launcher is disable
             System.Diagnostics.ProcessStartInfo start = new System.Diagnostics.ProcessStartInfo();
             start.Arguments = "-screen-fullscreen " + m_newFullScreen;
             start.FileName = exe;
             System.Diagnostics.Process.Start(start);
 
           //Quit the app
             Application.Quit();
 
           //Update the player pref because for some reason Screen.currentResolution doesn't work really well for me 
             PlayerPrefs.SetInt("resolution", m_ddResol.value);
     }

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

31 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

Related Questions

Standalone player in windows open fullscreen, but player settings says windowed 1 Answer

Comodo Firewall hangs Unity in fullscreen standalone mode 0 Answers

Borderless window in standalone player 5 Answers

bug or new feature ? 1 Answer

How do I bypass standalone config dialog? 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