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 /
avatar image
0
Question by spidermancy612 · Jan 15, 2018 at 04:25 AM · resolutionsettingsscreen size

How to set screen resolution

I'm trying to lock the screen resolution of a game I'm working on right now without success. From what I was able to find the typical way to do it is either through Screen.SetResolution or via the Player Settings under the project tab.

However when I try to set the screen resolution with code the game doesn't actually update the size but rather leaves it as is. When I try to go to Player Settings, the options for settings screen size are not there as shown in documentation pictures.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Propagant · Jan 15, 2018 at 05:54 AM

So essentially you want to keep the screen resolution static? Then it'd be great to use PlayerPrefs to store the resolution you want to keep. For example:

 public int LockResX = 1024;
 public in LockResY = 768;
 public bool Windowed = true;
 
 public bool SaveResolution = true;
 void Start()
 {
      if(SaveResolution)
      {
          PlayerPrefs.SetInt("ResX",LockResX);
          PlayerPrefs.SetInt("ResY",LockResY);
          Debug.Log("Resolution has been saved");
      }
      else if(PlayerPrefs.GetInt("ResX")!=null && PlayerPrefs.GetInt("ResY")!=null)
      {
       Screen.SetResolution(PlayerPrefs.GetInt("ResX"),PlayerPrefs.GetInt("ResY"),Windowed);
        Debug.Log("Resolution has been loaded");
      }
      else
         Debug.Log("There is no resolution saved");
 
 }




Basically I've made a 2 registry keys for PlayerPrefs as integers that store the resolution X and Y. If you enable SaveResolution the resolution LockResX and LockResY will be saved to the playerprefs after start. You can also enable/disable windowed mode [which is not saved and loaded after start]. Hope that helps.

Comment
Add comment · Show 1 · 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 spidermancy612 · Jan 15, 2018 at 02:51 PM 0
Share

Thanks for the code but that's not quite what I'm looking for. Right now I'm in full screen mode but I want to lock the resolution to a value I choose. The problem I'm having with it is that Screen.SetResolution isn't actually setting the resolution of the game. When I check the resolution after the game has started, it reports back whatever the size of my monitor is rather than the scale I've provided.

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

76 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

Related Questions

What are the most common screen resolutions to have in my options menu 1 Answer

Adjust camera for different screen sizes 0 Answers

How do I keep everything inside of the screen on a laptop? 2 Answers

Max screen resolution and delete the ones that are higher? 1 Answer

Ingame Quality Settings not recognized 1 Answer


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