Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 jFeas · Jan 06, 2015 at 04:09 PM · c#guiscreen

Screen.SetResolution in full screen issue

Hi fellow Uniters, i'm having an issue with the function Screen.SetResolution. I've set to modify the resolution in game (disabled the Display Resolution Dialog), but when i'm in full screen and switch resolution, i does :). But the old resolution stay in the background, i don't think that there are any errors, but if anyone here could help me i'll appreciate.

  • Normal: http://postimg.org/image/3v6kv1lzd/

  • Issue 1: http://postimg.org/image/70r6l94ll/

  • Issue 2: http://postimg.org/image/aj36hn5hl/

  • PS: If i swith tabs after setting the new resolution, the little bug disappears.

  • PS2: To find quickly the Resolution part, ctrl+F "// Set Window Resolution

Code:

 using UnityEngine;
 using System.Collections;
 
 public class _LobbyMenu : Photon.MonoBehaviour {
 
     public AudioSource _audioComponent;
     public AudioClip _windEffect;
 
     // Variaveis dos menus GUI
     public AudioClip _buttonPress;
     public Texture2D _gameLogo;
     public GUISkin _lobbySkin;
     private float _currentMenu;
     private float _screenCenterX;
     private float _screenCenterY;
 
     private int _screenResolution;
     private string _whichResolution;
     private int _screenQuality;
     private string _whichQuality;
     private bool _fullScreen;
 
     void Start ()
     {
         audio.loop = true;
         audio.clip = _windEffect;
         audio.volume = 0.25f;
         audio.PlayDelayed (1);
 
         _currentMenu = 0;
 
         if (PlayerPrefs.GetInt("_fullScreen") == 0)
             _fullScreen = true;
         if (PlayerPrefs.GetInt("_fullScreen") == 1)
             _fullScreen = false;
 
         _whichResolution = "";
         _screenResolution = PlayerPrefs.GetInt ("_screenResolution");
         _whichQuality = "";
         _screenQuality = PlayerPrefs.GetInt ("_screenQuality");
 
         Debug.Log (QualitySettings.names.Length);
     }
 
     void Update ()
     {
         _screenCenterX = Screen.width / 2;
         _screenCenterY = Screen.height / 2;
 
         transform.Rotate(Vector3.up * Time.deltaTime, Space.World);
     }
 
     void OnGUI ()
     {
         GUI.skin = _lobbySkin;
 
         if(_currentMenu == 0) StartMenu();
         if(_currentMenu == 1) SinglePlayerMenu();
         if(_currentMenu == 2) MultiPlayerMenu();
         if(_currentMenu == 3) OptionsMenu();
         if(_currentMenu == 4) ExitMenu();
     }
 
     void StartMenu ()
     {    
         GUI.DrawTexture (new Rect(_screenCenterX - 512/2, _screenCenterY - 64 * 2, 512, 64), _gameLogo);
 
         GUI.BeginGroup (new Rect(_screenCenterX - 256/2, _screenCenterY, 256, 128+15));
         if(GUI.Button (new Rect(0, 0, 256, 32), "Single Player")) 
         {
             audio.PlayOneShot(_buttonPress);
             _currentMenu = 1;
         }
         if(GUI.Button (new Rect(0, 37, 256, 32), "Multi Player")) 
         {
             audio.PlayOneShot(_buttonPress);
         }
         if(GUI.Button (new Rect(0, 74, 256, 32), "Options")) 
         {
             audio.PlayOneShot(_buttonPress);
             _currentMenu = 3;
         }
         if(GUI.Button (new Rect(0, 111, 256, 32), "Exit")) 
         {
             audio.PlayOneShot(_buttonPress);
         }
         GUI.EndGroup ();
     }
     
     void SinglePlayerMenu ()
     {
         GUI.DrawTexture (new Rect(_screenCenterX - 512/2, _screenCenterY - 64 * 2, 512, 64), _gameLogo);
         
         GUI.BeginGroup (new Rect(_screenCenterX - 256/2, _screenCenterY, 256, 64+5));
         GUI.Box (new Rect(0, 0, 256, 32), "The following feature is desabled.");
 
         if(GUI.Button (new Rect(0, 37, 256, 32), "Back")) 
         {
             audio.PlayOneShot(_buttonPress);
             _currentMenu = 0;
         }
         GUI.EndGroup ();
     }
 
     void MultiPlayerMenu ()
     {
     }
 
     void OptionsMenu ()
     {
         GUI.DrawTexture (new Rect(_screenCenterX - 512/2, _screenCenterY - 64 * 2, 512, 64), _gameLogo);
         GUI.BeginGroup (new Rect(_screenCenterX - 256/2, _screenCenterY, 256, 256));
 
         GUI.Box(new Rect(0, 0, 256, 182), "");
 
         // Set Window Resolution
         GUI.Label(new Rect(10, 10, 236, 25), "Resolution: " + _whichResolution);
         _screenResolution = Mathf.RoundToInt(GUI.HorizontalSlider(new Rect(10, 40, 236, 30), _screenResolution, 0, 6));
         if (_screenResolution == 0)
             _whichResolution = "800 x 600";
         if (_screenResolution == 1)
             _whichResolution = "1024 x 768";
         if (_screenResolution == 2)
             _whichResolution = "1280 x 600";
         if (_screenResolution == 3)
             _whichResolution = "1280 x 720";
         if (_screenResolution == 4)
             _whichResolution = "1280 x 768";
         if (_screenResolution == 5)
             _whichResolution = "1360 x 768";
         if (_screenResolution == 6)
             _whichResolution = "1366 x 768";
 
         // Set Image Quality
         GUI.Label(new Rect(10, 75, 236, 25), "Quality: " + _whichQuality);
         _screenQuality = Mathf.RoundToInt(GUI.HorizontalSlider(new Rect(10, 105, 236, 30), _screenQuality, 0, 4));
         if (_screenQuality == 0)
             _whichQuality = "Fast";
         if (_screenQuality == 1)
             _whichQuality = "Simple";
         if (_screenQuality == 2)
             _whichQuality = "Good";
         if (_screenQuality == 3)
             _whichQuality = "Beautiful";
         if (_screenQuality == 4)
             _whichQuality = "Fantastic";
 
         GUI.Label(new Rect(10, 140, 236, 25), "Full Screen ");
         _fullScreen = GUI.Toggle(new Rect(85, 143, 16, 16), _fullScreen, "");
 
         if(GUI.Button (new Rect(0, 256 - 69, 256, 32), "Apply")) 
         {
             audio.PlayOneShot(_buttonPress);
 
             if (_screenResolution == 0)
                 Screen.SetResolution(800, 600, _fullScreen);
             if (_screenResolution == 1)
                 Screen.SetResolution(1024, 768, _fullScreen);
             if (_screenResolution == 2)
                 Screen.SetResolution(1280, 600, _fullScreen);
             if (_screenResolution == 3)
                 Screen.SetResolution(1280, 720, _fullScreen);
             if (_screenResolution == 4)
                 Screen.SetResolution(1280, 768, _fullScreen);
             if (_screenResolution == 5)
                 Screen.SetResolution(1360, 768, _fullScreen);
             if (_screenResolution == 6)
                 Screen.SetResolution(1366, 768, _fullScreen);
 
             if (_screenQuality == 0)
                 QualitySettings.SetQualityLevel(1, true);
             if (_screenQuality == 1)
                 QualitySettings.SetQualityLevel(2, true);
             if (_screenQuality == 2)
                 QualitySettings.SetQualityLevel(3, true);
             if (_screenQuality == 3)
                 QualitySettings.SetQualityLevel(4, true);
             if (_screenQuality == 4)
                 QualitySettings.SetQualityLevel(5, true);
 
             PlayerPrefs.SetInt("_screenResolution", _screenResolution);
             PlayerPrefs.SetInt("_screenQuality", _screenQuality);
 
             if(_fullScreen == true)
                 PlayerPrefs.SetInt("_fullScreen", 0);
             else
                 PlayerPrefs.SetInt("_fullScreen", 1);
         }
 
         if(GUI.Button (new Rect(0, 256 - 32, 256, 32), "Back")) 
         {
             audio.PlayOneShot(_buttonPress);
             _currentMenu = 0;
         }
 
         GUI.EndGroup ();
     }
 
     void ExitMenu ()
     {
     }
 }


Comment
Add comment · Show 3
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 Graham-Dunnett ♦♦ · Jan 06, 2015 at 04:16 PM 0
Share

How do you know the device supports those resolutions?

avatar image Graham-Dunnett ♦♦ · Jan 06, 2015 at 04:16 PM 0
Share

Also: http://forum.unity3d.com/threads/unity-max-resolution-error.289333/ may be related.

avatar image jFeas · Jan 06, 2015 at 05:48 PM 0
Share

i tried in my 1366x768 monitor and a small one, the same error occurred

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Distribute terrain in zones 3 Answers

Unity 3d C# GUI box goes off to the side needs to be in the center of the screen 0 Answers

Multiple Cars not working 1 Answer

Displaying score on screen in specific place 1 Answer

GUI.DrawTexture Center on screen 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