Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

can't change resolution for standalone build

Discussion in 'Editor & General Support' started by ullman, May 6, 2015.

  1. ullman

    ullman

    Joined:
    Dec 29, 2014
    Posts:
    7
    I posted this on Unity answers and didn't get any answer, so I'm posting it here.

    Ok, I just updated to Unity 5, and I've been trying to figure this out for long while now. No matter what resolution I set for windows standalone player settings, I get the same 720:480 resolution. I've turned off/on the display resolution dialog. looked around in the settings. Nothing. All I get is the default 730:480... I tried to do it through code just to see what happens and it's completely ignored. I even set full resolution to false and it went fullscreen. All the aspect ratio settings in the player settings are checked. The resolution looks fine in the game preview window, but does not translate into the final build.

    Anyone can tell me what I'm doing wrong here?
     
  2. jough

    jough

    Joined:
    Aug 18, 2013
    Posts:
    41
    Hey there ullman,
    I think I may have come across the answer for you a littler earlier after some searching. I really hope it's a bug and not a feature.

    Whenever you build a new game using Unity, it saves a registry key (in windows) or a preference file (On Mac) under the Company Name You selected for the player settings. By default, this is “DefaultCompany”.

    The registry key or preference file will still contain old display settings and other settings that are NOT over-written when you hit build, if you are building using the same Company Name. This will lead to Unity using the nearest resolution to what you have selected as a standard resolution supported by the video card.

    To fix this, locate the following registry key in windows - HKCU\Software\[company name]\[product name]and delete the entire key and rebuild, then run the game. You can access your registy by typing "regedit" (without the quotes) into your windows search, or if you are using Win8 you can hit the windows key and just type "regedit" (without the quotes) and windows will locate it for you.

    In Mac, delete the corresponding preferences file located in ~/Library/Preferences/unity


    Source: http://cinema-suite.com/unity-tip-running-a-custom-fullscreen-resolution/
     
  3. ullman

    ullman

    Joined:
    Dec 29, 2014
    Posts:
    7
    Wow, this actually worked. I was beginning to question my own sanity after the last couple of days. Phew. Thanks a lot for your help!
     
    rklausch likes this.
  4. michealcaj

    michealcaj

    Joined:
    Aug 18, 2017
    Posts:
    143
  5. Grarafka

    Grarafka

    Joined:
    Aug 24, 2016
    Posts:
    1
    worked like a charm!
     
  6. oultrox

    oultrox

    Joined:
    Oct 4, 2016
    Posts:
    3
    Thank you so much for this!
     
  7. Zante

    Zante

    Joined:
    Mar 29, 2008
    Posts:
    413
    Yes, thanks. I can't believe this hasn't been addressed in three years?

    I'm creating an app launcher in Unity 5.6 (as 2017 uses libcurl which stops files being accessed from my server).

    Deleting the registry key, as mentioned, works like a charm. This is not an intuitive solution and it still presents me with the problem of how to modify this on any clients/launchers I distribute.
     
    Last edited: May 21, 2018
  8. lightcollector

    lightcollector

    Joined:
    Aug 10, 2018
    Posts:
    1
    Oh great! I was beginning to getting mad at this problem. Worked perfectly.

    Just to point that HKCU refers to "hkey_current_user" for future windows noobs like me.

    Thanks so much!
     
  9. BrienKing

    BrienKing

    Joined:
    Oct 11, 2015
    Posts:
    35
    Thank you, I was pulling my hair out on this one too!
     
  10. Random_100

    Random_100

    Joined:
    Jan 28, 2019
    Posts:
    1
    I can't seem to get this to work.
     
  11. Slimboy1990

    Slimboy1990

    Joined:
    Jul 10, 2018
    Posts:
    2
    I honestly dont understand why this has not been fixed yet. I really start to doubt the capability of unity.

    Thank you a thousand times mate.
     
  12. CaseyHofland

    CaseyHofland

    Joined:
    Mar 18, 2016
    Posts:
    62
    This is working for the resolution, but I have a looot of trouble to change the fullscreen mode, honestly it seems to happen at random. I delete the regedit, restart Unity, nothing. Then, after doing this 2 more times for other reasons (fullscreen switch, single instance) it suddenly decides to finally save my changes!

    EDIT:
    So I found out that the "Fullscreen Mode" Setting is... different than I thought. I think a better name for it would be "Default Screen Mode". Apparently, the screen mode you select is what the game will open with the first time you play it, where as I though it meant what the executable understood under "fullscreen" (windowed, for example, being a maximized window). After a bit of studying up in the documentation things are starting to get more clear, but it's still annoying how much of a hassle this seemingly simple issue actually is.
     
    Last edited: Jun 3, 2019
  13. mythoflight

    mythoflight

    Joined:
    Apr 11, 2016
    Posts:
    1
    Thank you, jough!! Four and a half years later and your solution still works exactly as described, haha!
     
    Circool likes this.
  14. rwslab

    rwslab

    Joined:
    Jun 4, 2019
    Posts:
    1
    Thank you, this was very helpful.
     
  15. NickVst

    NickVst

    Joined:
    Feb 17, 2017
    Posts:
    23
    Came across this issue myself today, so I wrote a script that automates deleting the relevant keys.

    Simply put the below script in a folder at
    Assets/Editor
    and a new menu will popup in the menubar.

    Code (CSharp):
    1.  
    2. using System;
    3. using System.Collections.Generic;
    4. using System.Linq;
    5. using Microsoft.Win32;
    6. using UnityEditor;
    7. using UnityEngine;
    8.  
    9. public class CleanRegistryKey
    10. {
    11.     [MenuItem("Registry/Clean Unity Build registry items")]
    12.     static void Clean()
    13.     {
    14.         string keyPath = String.Format(
    15.             "SOFTWARE\\{0}\\{1}",
    16.             PlayerSettings.companyName,
    17.             PlayerSettings.productName
    18.         );
    19.  
    20.         using (RegistryKey key = Registry.CurrentUser.OpenSubKey(keyPath, true))
    21.         {
    22.             if (key == null) // Key doesn't exist
    23.             {
    24.                 Debug.LogWarning("Could not find key. Have you built this project at least once?\n"
    25.                                  + "Key tried: " + keyPath);
    26.                 return;
    27.             }
    28.  
    29.             List<string> screenManagerVals = key.GetValueNames()
    30.                 .Where(x => x.StartsWith("Screenmanager"))
    31.                 .ToList();
    32.  
    33.             if (!screenManagerVals.Any())
    34.             {
    35.                 Debug.LogWarning("There were no 'Screenmanager' values in the registry. " +
    36.                                  "Have you cleaned this key before?\n" +
    37.                                  "Key tried: " + keyPath);
    38.                 return;
    39.             }
    40.  
    41.             foreach (string value in screenManagerVals)
    42.             {
    43.                 // These keys all have to do with setting screen size / type.
    44.                 Debug.Log("Deleting value: " + value);
    45.                 key.DeleteValue(value);
    46.             }
    47.            
    48.             Debug.Log("Successfully deleted the 'Screenmanager' values.");
    49.         }
    50.     }
    51. }
    52.  
     
    fffMalzbier likes this.
  16. Vectorbox

    Vectorbox

    Joined:
    Jan 27, 2014
    Posts:
    205
    Alternatively, you can set the screen resolution from your script. When you run the build it will adopt the new resolution which will subsequently become the default build setting.

    The third parameter (boolean) disables / enables full screen mode.

    Example

    Code (csharp):
    1.  
    2. void Awake() {
    3.     Screen.SetResolution(640, 360, false);
    4. }
    5.  
     
  17. darkAbacus247

    darkAbacus247

    Joined:
    Sep 7, 2010
    Posts:
    235
    [QUOTE="jough, post: 2100981, member: 384609]
    To fix this, locate the following registry key in windows - HKCU\Software\[company name]\[product name]
    [/QUOTE]

    Many thanks, what a silly "error".
     
unityunity