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 AR_Rizvi · May 13, 2016 at 07:22 AM · c#screenresolution settings

Resolution Switch In Game Not Working Properly

I am trying to change the resolution in my game.

I want may game to start on a given resolution defined in Script and after that as per user input, But when i do that my screen just go black and nothing happen a prat from the size of my windowed game changes. I have been searching for this but i am not been able to find a solution for what i am experiencing, everything just stuck and i dose not move at all

This is the code i am using

This is where my resolution is being set on play

 void Awake()
     {
         resolutionPopup.value = "1024x768";
         SetResolution("1024x768", false);
         graphicsPopup.value = "Fantastic";
         SetQuality(5);
     }

this is where It gets the supported resolutions and add them to my popup window

 void Start () {
     
         GetRes();
         GetQuality();
         NumberOfMonitors();
         Debug.Log("Start");
 
     }

this is where i am getting all suported resolutions of monitor

 void GetRes()
 {
     Resolution[] resolutions = Screen.resolutions;
     foreach (Resolution res in resolutions)
     {
     
         string resolution = res.width.ToString() + "x" + res.height.ToString();

         SetDropDowmResolution(resolution);
     }
 }

this is the method which sets the resolution in to popup

 void SetDropDowmResolution(string res)
 {
     resolutionPopup.items.Add(res);
 }

this is where my selected resolution is being set

  void SetResolution(string res, bool fullscreen)
 {
     string[] resBreak = res.Split('x');
     Vector2 resV2 = new Vector2(Int32.Parse(resBreak[0]), Int32.Parse(resBreak[1]));

     Screen.SetResolution((int)resV2.x, (int)resV2.y, fullscreen);

    
 }

i am using Set Resolution Method GUI button Plz look into this matter as i am unable to solve it... Thanks

Comment
Add comment · Show 1
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 AR_Rizvi · May 17, 2016 at 10:44 AM 0
Share

Come on Guys help me out here

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Naphier · May 13, 2016 at 09:42 AM

Does the same thing happen if you set the resolution in the player settings, but then later try to change it via code? It shouldn't matter, but maybe it does and maybe you need to set the supported orientations. I use this method in my Mobile Store Screenshot Helper asset that does this, I just built it with Unit 5.3.4p5 and it works 100%.

So I can only assume that there's an error in your code (I'd check those values you're actually setting the resolution to) or it's some conflict with the Player Settings. Attaching screencaps of mine in case it helps. alt text alt text


playersettings.png (31.3 kB)
playersettings1.png (30.7 kB)
Comment
Add comment · Show 2 · 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 AR_Rizvi · May 13, 2016 at 10:37 AM 0
Share

Thanks Naphier but i have unity 5.2.1f1 pro and i have cross checked my player settings from your images but i have noting which is in common so the issue stands

Can u check my code whether it has a problem or not

avatar image Naphier AR_Rizvi · May 17, 2016 at 04:26 PM 0
Share

I see no immediate issues with your code. I can only suggest that you do some debugging of the following method:

   void SetResolution(string res, bool fullscreen)
  {
      string[] resBreak = res.Split('x');
      Vector2 resV2 = new Vector2(Int32.Parse(resBreak[0]), Int32.Parse(resBreak[1]));
      Screen.SetResolution((int)resV2.x, (int)resV2.y, fullscreen);
     
  }

One item that is unnecessary is the vector2. You're creating a new vector2 with parsed ints then casting the x & y of the vector2 back to ints. That shouldn't be the problem, but it's unnecessary. You need to put in a debug statement here to see what's really being passed to SetResolution.

Like I said, SetResolution works perfectly for me so it's either your code (which you'll need to deter$$anonymous$$e the errors by debugging) or it's something to do with your Player settings (which can be deter$$anonymous$$ed by taking your code to a new test project). It's also possible that you're using the GUI incorrectly, which we can only guess about because we can't see your hierarchy and button events.

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

143 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 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

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

how to make my game for all screen please ? 1 Answer

Changing screen resolution is cutting the very edge of my screen off 1 Answer

Flip over an object (smooth transition) 3 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