• 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 thanujc · Oct 14, 2015 at 09:48 AM · screen resolutionunity 5.2

Screen.currentResolution with Unity 5.2.1

We are using unity to develop a desktop application, and we were using Unity 4 previously. Now we have upgraded our project to Unity 5 (5.2.1). We have an issue with setting the screen resolution. We used Screen.SetResolution (Screen.currentResolution.width, Screen.currentResolution.height, true); in Unity 4 to set the resolution and it works fine. But in unity5 Screen.currentResolution.width doesn't gives the correct value. Is there anything new with Unity 5.2.1 ?

Comment
Add comment · Show 2
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 DiegoSLTS · Oct 14, 2015 at 02:16 PM 0
Share

What do you mean by "doesn't give the correct value"? Always 0? Some random value?

According to the documentation:

The current screen resolution (Read Only).

If the player is running in window mode, this returns the current resolution of the desktop.

From your code I suppose you're setting your game to fullscreen, so, currentResolution should return the native resolution but it isn't?

Also, maybe it's important to tell what's the platform you're building for.

avatar image yoonitee · Dec 27, 2017 at 02:00 AM 0
Share

Did you ever find a solution? This appears to be a but in Unity 5

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Halichoerus · Oct 14, 2015 at 05:50 PM

Same thing happened to me, I just used Screen.width and Screen.height to get the current resolutions, and Screen.resolutions for a list of supported full screen resolutions (last element in the array being the largest).

This should work for you, you can even cycle though this array in your options menu so the player can adjust resolution.

 Resolution[] allRes = Screen.resolutions;
 Screen.SetResolution(allRes[allRes.Length-1].width, allRes[allRes.Length - 1].height, true);

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 xenix2012 · Jan 09, 2016 at 02:37 PM 0
Share

It works fine for me, thanks!

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Can i set my work to be played at a single screen resolution only to prevent scaling issues? 0 Answers

Camera Fit Issues on 10 inch tablet 0 Answers

How can I fix the screen disturbance of android 4.1/4.2 ? 0 Answers

How to adjust virtual joystick itself movement (not size) on different mobile resolutions using c# in unity 2d? 0 Answers

Unity 5.2: Profiling Empty Scene - Very high Graphics.PresetAndSync 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