Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Set windowed mode default size

Discussion in 'Editor & General Support' started by JohnGaby, Aug 16, 2018.

  1. JohnGaby

    JohnGaby

    Joined:
    Jul 9, 2017
    Posts:
    7
    I am trying to build a version for windows that runs in windowed mode. I would like to be able to set the default width and height for the window. However no matter what I do, the window is always created at the maximum resolution of my display. I have the following settings:


    It seems like there must be something obvious that I am missing.

    Any help would be appreciated.
     
  2. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    One you have startet the application at a resoltuon the application saves the resolution on the systhem and will start with it the nextime so your default with / height are ignored.
     
  3. JohnGaby

    JohnGaby

    Joined:
    Jul 9, 2017
    Posts:
    7
    Thanks for the info, but where exactly is this information stored. I tried deleting the entire build folder and rebuilding the project, but the window still starts at the size of the current screen resolution.
     
  4. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    On windows its stored under the windows Registry (regedit.exe)
    Computer\HKEY_CURRENT_USER\Software\CompanyName\ApplicationName
     
  5. JohnGaby

    JohnGaby

    Joined:
    Jul 9, 2017
    Posts:
    7
    Ok, found it. Thanks for the help.
     
  6. JohnGaby

    JohnGaby

    Joined:
    Jul 9, 2017
    Posts:
    7
    Ok, now I am having trouble with this on the Mac. When I first installed the app, the screen was the correct size. However, I made the mistake of clicking the window's maximize button (this button is disabled on the Windows version). This resulted in a window that was the incorrect size and now the app is stuck in that size even if I close it and restart it. Is the window size stored somewhere like it is for Windows?

    Thanks
     
  7. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    Any way to let Unity ignore the registry-saved windowsize and open the app with a windowsize that I define?
     
  8. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,900
    Cascho01 likes this.
  9. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    Didn´t know about this and it works, thanks!

    I did this by editing the shortcut>target:
    ...myApp.exe -screen-fullscreen 0 -screen-width 800 -screen-height 400

    Any way to implement this directly in the editor?
     
    Last edited: Jul 31, 2020
  10. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,900
    https://docs.unity3d.com/Manual/BuildPlayerPipeline.html
     
  11. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    After all, I´m not happy with my solution to add -screen-fullscreen 0 -screen-width 800 -screen-height 400 to my shortcut.
    This way I can´t send it to my clients, because the path inside my shortcut is hardcoded and of course its different on my clients pc.

    Any better idea?
     
  12. josephgabbay

    josephgabbay

    Joined:
    Jun 1, 2018
    Posts:
    2
    Cascho01 nice solution, it is also possible to use Unity Editor: Edit->Project Settings...
    and then select "Player" from left pane and see "Resolution and Presentation" change it to windowed mode.

    When changing the project settings in Visual Studio 2019, it seems that Visual Studio takes the precedence and it cannot be reverted