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 CFF · Dec 30, 2012 at 11:25 PM · guiresolutionanti-aliasing

Anti Alliasing is affecting an part of my GUI negatively

Okey so I have been buidling an settings menu sort of for my project that aloows you to change surten settings which are: Resolution,Anti alliasing,V sync and the Texture quality.

However I have one bug that I just don't understand. with QualitySettings.antiAliasing and my dropdown window for the resolutions.

if QualitySettings.antiAliasing = 0 it looks like it should. But if I have QualitySettings .antiAliasing on any value higher then 0 the resolutions dropdown window will all off a sudden show with stripes in between the GUI textures.

my script:

using UnityEngine;

using System.Collections;

using System.Collections.Generic;

using System.Text;

using System.Xml;

using System.IO;

public class SettingsMenu : MonoBehaviour {

 Resolution [] Resolutions;
 int a;
 
 public Texture Background;
 
 public GUIStyle Accept;
 public GUIStyle Cancel;
 
 public GUIStyle EmptyButton;
 public GUIStyle EmptyListButton;
 public GUIStyle USEmptyButton;
 
 bool accepting;
 bool Cancelling;
 
 public Texture ResoText;
 public Texture RefreshText;
 public Texture AAText;
 public Texture VsyncText;
 public Texture TextureQText;
 
 int OldWidthReso;
 int OldHeightReso;
 bool Reso;
 
 int OldAA;
 bool AA;
 
 int OldVsync;
 bool Vsync;
 
 int OldTextureQ;
 bool TextureQ;
 
 Vector2 DropDown = Vector2.zero;
 
 string filepath;
 
 Vector3 scale;
 
 void Awake(){
     filepath = Application.dataPath + "/Settings.xml";
     
     Resolutions = Screen.resolutions;
     
     foreach(Resolution res in Resolutions){
         a++;
     }
     
     a = a - 1;
     
     if(File.Exists(filepath)){
         using (XmlReader reader = XmlReader.Create(filepath)){
             while (reader.Read()){
                 if(reader.NodeType == XmlNodeType.Element && reader.Name == "resolution_x"){
                     OldWidthReso =  XmlConvert.ToInt32(reader.ReadString());
                 }
                 
                 if(reader.NodeType == XmlNodeType.Element && reader.Name == "resolution_y"){
                     OldHeightReso =  XmlConvert.ToInt32(reader.ReadString());
                 }
                 
                 if(reader.NodeType == XmlNodeType.Element && reader.Name == "anti_alliasing"){
                     QualitySettings.antiAliasing = XmlConvert.ToInt32(reader.ReadString());
                 }
                 
                 if(reader.NodeType == XmlNodeType.Element && reader.Name == "v_sync"){
                     QualitySettings.vSyncCount = XmlConvert.ToInt32(reader.ReadString());
                 }
                 
                 if(reader.NodeType == XmlNodeType.Element && reader.Name == "texture_quality"){
                     QualitySettings.masterTextureLimit = XmlConvert.ToInt32(reader.ReadString());
                 }
             }
         }    
         Screen.SetResolution(OldWidthReso,OldHeightReso,true,Resolutions[a].refreshRate);
     }
     else{
         QualitySettings.vSyncCount = 0;
         
         Screen.SetResolution(Resolutions[a].width,Resolutions[a].height,true,Resolutions[a].refreshRate);
     }
 }
 
 void Start(){
     OldWidthReso = Screen.width;
     OldHeightReso = Screen.height;
     
     OldAA = QualitySettings.antiAliasing;
     
     OldVsync = QualitySettings.vSyncCount;
     
     OldTextureQ = QualitySettings.masterTextureLimit;
 }
 
 // Update is called once per frame
 void OnGUI() {
     scale.x = Screen.width / 1920.0f;
     scale.y = Screen.height / 1080.0f;
     scale.z = 1.0f;
     
     Matrix4x4 SvMat = GUI.matrix;
     
     GUI.matrix = Matrix4x4.TRS(Vector3.zero,Quaternion.identity,scale);
     
     if(Mainmenu.Menu == Mainmenu.Menus.Settings){
         Settings();    
     }
     
     GUI.matrix = SvMat;
 }
 
 void Settings(){
     GUI.DrawTexture(new Rect(0,230,1920,808),Background);
     
     if(GUI.Button(new Rect(1561,945,299,40),"",Accept)){
         accepting = true;
         Mainmenu.Menu = Mainmenu.Menus.StartMenu;    
     }
     
     if(accepting == true){
         accept();
     }
     
     if(GUI.Button(new Rect(1212,945,299,40),"",Cancel)){
         Cancelling = true;
     }
     
     if(Cancelling == true){
         cancel();    
     }
     
     //Texture Quality
     GUI.DrawTexture(new Rect(810,333,299,40),TextureQText);
     
     if(TextureQ == false){
         if(QualitySettings.masterTextureLimit == 0){
             if(GUI.Button(new Rect(810,370,299,40),"Fantastic",EmptyButton)){
                 TextureQ  = true;
             }
         }
         
         if(QualitySettings.masterTextureLimit == 2){
             if(GUI.Button(new Rect(810,370,299,40),"High",EmptyButton)){
                 TextureQ  = true;
             }
         }
         
         if(QualitySettings.masterTextureLimit == 4){
             if(GUI.Button(new Rect(810,370,299,40),"Medium",EmptyButton)){
                 TextureQ  = true;
             }
         }
         
         if(QualitySettings.masterTextureLimit == 8){
             if(GUI.Button(new Rect(810,370,299,40),"Low",EmptyButton)){
                 TextureQ  = true;
             }
         }
     }
     
     if(TextureQ == true){
         if(QualitySettings.masterTextureLimit == 0){
             if(GUI.Button(new Rect(810,370,299,40),"Fantastic",EmptyButton)){
                 TextureQ  = false;
             }
         }
         
         if(QualitySettings.masterTextureLimit == 2){
             if(GUI.Button(new Rect(810,370,299,40),"High",EmptyButton)){
                 TextureQ  = false;
             }
         }
         
         if(QualitySettings.masterTextureLimit == 4){
             if(GUI.Button(new Rect(810,370,299,40),"Medium",EmptyButton)){
                 TextureQ  = false;
             }
         }
         
         if(QualitySettings.masterTextureLimit == 8){
             if(GUI.Button(new Rect(810,370,299,40),"Low",EmptyButton)){
                 TextureQ  = false;
             }
         }
         

         DropDown = GUI.BeginScrollView(new Rect(810,410,299,160),DropDown, new Rect(0,0,299,160));
             if(GUI.Button(new Rect(0,0,299,40),"Fantastic",EmptyListButton)){
                 OldTextureQ = QualitySettings.masterTextureLimit;
                 QualitySettings.masterTextureLimit = 0;
                 TextureQ  = false;
             }    
         
             if(GUI.Button(new Rect(0,40,299,40),"High",EmptyListButton)){
                 OldTextureQ = QualitySettings.masterTextureLimit;
                 QualitySettings.masterTextureLimit = 2;
                 TextureQ  = false;
             }
         
             if(GUI.Button(new Rect(0,80,299,40),"Medium",EmptyListButton)){
                 OldTextureQ = QualitySettings.masterTextureLimit;
                 QualitySettings.masterTextureLimit = 4;
                 TextureQ  = false;
             }    
         
             if(GUI.Button(new Rect(0,120,299,40),"Low",EmptyListButton)){
                 OldTextureQ = QualitySettings.masterTextureLimit;
                 QualitySettings.masterTextureLimit = 8;
                 TextureQ  = false;
             }
             
         GUI.EndScrollView();
     }
     
     //Vsync
     GUI.DrawTexture(new Rect(60,333,299,40),VsyncText);
     
     if(Vsync == false){
         if(QualitySettings.vSyncCount == 0){
             if(GUI.Button(new Rect(60,370,299,40),"Disabled",EmptyButton)){
                 Vsync = true;
             }
         }
         
         if(QualitySettings.vSyncCount == 2){
             if(GUI.Button(new Rect(60,370,299,40),"Enabled",EmptyButton)){
                 Vsync = true;
             }
         }
     }
     
     if(Vsync == true){
         if(QualitySettings.vSyncCount == 0){
             if(GUI.Button(new Rect(60,370,299,40),"Disabled",EmptyButton)){
                 Vsync = false;
             }
         }
         
         if(QualitySettings.vSyncCount == 2){
             if(GUI.Button(new Rect(60,370,299,40),"Enabled",EmptyButton)){
                 Vsync = false;
             }
         }

         DropDown = GUI.BeginScrollView(new Rect(60,410,299,160),DropDown, new Rect(0,0,299,160));
             if(GUI.Button(new Rect(0,0,299,40),"Disabled",EmptyListButton)){
                 OldVsync = QualitySettings.vSyncCount;
                 QualitySettings.vSyncCount = 0;
                 Vsync = false;
             }    
         
             if(GUI.Button(new Rect(0,40,299,40),"Enabled",EmptyListButton)){
                 OldVsync = QualitySettings.vSyncCount;
                 QualitySettings.vSyncCount = 2;
                 Vsync = false;
             }
             
         GUI.EndScrollView();
     }
     
     //multisampling
     GUI.DrawTexture(new Rect(1561,253,299,40),AAText);
     
     if(AA == false){
         if(GUI.Button(new Rect(1561,290,299,40),QualitySettings.antiAliasing.ToString() + "x Multisampling",EmptyButton)){
             AA = true;
         }
     }
     
     if(AA == true){
         if(GUI.Button(new Rect(1561,290,299,40),QualitySettings.antiAliasing.ToString() + "x Multisampling",EmptyButton)){
             AA = false;
         }
         

         DropDown = GUI.BeginScrollView(new Rect(1561,330,299,160),DropDown, new Rect(0,0,299,160));
             if(GUI.Button(new Rect(0,0,299,40)," 0x Multisampling",EmptyListButton)){
                 OldAA = QualitySettings.antiAliasing;
                 QualitySettings.antiAliasing = 0;
                 AA = false;
             }    
         
             if(GUI.Button(new Rect(0,40,299,40)," 2x Multisampling",EmptyListButton)){
                 OldAA = QualitySettings.antiAliasing;
                 QualitySettings.antiAliasing = 2;
                 AA = false;
             }
         
             if(GUI.Button(new Rect(0,80,299,40)," 4x Multisampling",EmptyListButton)){
                 OldAA = QualitySettings.antiAliasing;
                 QualitySettings.antiAliasing = 4;
                 AA = false;
             }    
         
             if(GUI.Button(new Rect(0,120,299,40)," 8x Multisampling",EmptyListButton)){
                 OldAA = QualitySettings.antiAliasing;
                 QualitySettings.antiAliasing = 8;
                 AA = false;
             }
             
         GUI.EndScrollView();
     }
     
     //Refresh Rate
     GUI.DrawTexture(new Rect(810,253,299,40),RefreshText);
     
     GUI.Box(new Rect(810,290,299,40),Resolutions[a -1].refreshRate.ToString() +"Hz",USEmptyButton);
     
     //Resolutions
     GUI.DrawTexture(new Rect(60,253,299,40),ResoText);
     
     if(Reso == false){
         if(GUI.Button(new Rect(60,290,299,40),Screen.width.ToString() + "x" + Screen.height.ToString(),EmptyButton)){
             Reso = true;
         }
     }
     
     if(Reso == true){
         if(GUI.Button(new Rect(60,290,299,40),Screen.width.ToString() + "x" + Screen.height.ToString(),EmptyButton)){
             Reso = false;
         }
         
         for(int i = 0; i < a+1; i++){
         DropDown = GUI.BeginScrollView(new Rect(60,330,299,40 +(i * 40)),DropDown, new Rect(0,0,299,40 +(i * 40)));
             
             if(GUI.Button(new Rect(0,0 + (i*40),299,40),Resolutions[i].width + "x" + Resolutions[i].height,EmptyListButton)){
                 OldWidthReso = Screen.width;
                 OldHeightReso = Screen.height;
                 Screen.SetResolution(Resolutions[i].width,Resolutions[i].height,true);
                 Reso = false;
             }
             
             GUI.EndScrollView();
         }
     }
 }
 
 
 
 
 
 
 void cancel(){
         if(OldWidthReso != Screen.width || OldHeightReso != Screen.height){
             Screen.SetResolution(OldWidthReso,OldHeightReso,true);    
         }
     
         if(OldAA != QualitySettings.antiAliasing){
             QualitySettings.antiAliasing = OldAA;
         }
     
         if(OldVsync != QualitySettings.vSyncCount){
             QualitySettings.vSyncCount = OldVsync;    
         }
     
         if(OldTextureQ != QualitySettings.masterTextureLimit){
             QualitySettings.masterTextureLimit = OldTextureQ;
         }
     
         Cancelling = false;
 }
 
 
 
 
 
 
 void accept(){
     OldWidthReso = Screen.width;    
     OldHeightReso = Screen.height;
     OldAA = QualitySettings.antiAliasing;
     OldVsync = QualitySettings.vSyncCount;
     OldTextureQ = QualitySettings.masterTextureLimit;
     
     //saving
     using (XmlWriter writer = XmlWriter.Create(filepath))
     {    
             writer.WriteStartDocument();
         writer.WriteStartElement("SettingsValues");
         
         writer.WriteStartElement("Resolution_X");
             writer.WriteElementString("resolution_x", OldWidthReso.ToString());
         writer.WriteEndElement();
         
         writer.WriteStartElement("Resolution_Y");
             writer.WriteElementString("resolution_y", OldHeightReso.ToString());
         writer.WriteEndElement();
         
         writer.WriteStartElement("Anti_Alliasing");
             writer.WriteElementString("anti_alliasing", OldAA.ToString());
         writer.WriteEndElement();
         
         writer.WriteStartElement("V_Syncing");
             writer.WriteElementString("v_sync", OldVsync.ToString());
         writer.WriteEndElement();
         
         writer.WriteStartElement("TextureQuality");
             writer.WriteElementString("texture_quality", OldTextureQ.ToString());
         writer.WriteEndElement();
         
         writer.WriteEndElement();
         writer.WriteEndDocument();
     }
     
     accepting = false;
 }

}

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

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

8 People are following this question.

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

Related Questions

Rendering GUI.Buttons in the middle of the screen 5 Answers

Rescale GUITexture Android/IOS 1 Answer

Scaling GUI When Screen Width is Adjusted 1 Answer

Resolution question? 0 Answers

GUI Buttons scaling with resolution - help 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