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 javanoob · Apr 21, 2013 at 07:56 PM · menupausequality

Pause Menu Quality Settings Error ?

Hi bit stuck here guys ,usinf the PauseMenu off the Wiki (which works great BTW) but the Quality Settings is giving me this Error but I am not certain what to change and where ,can anyone point out the obvious please :)

Assets/PauseMenu.cs(238,35): warning CS0618: UnityEngine.QualityLevel' is obsolete: See QualitySettings.names, QualitySettings.SetQualityLevel, and QualitySettings.GetQualityLevel'

======================= PauseMenu.cs =========================

 using UnityEngine;
 using System.Collections;
  
 public class PauseMenu : MonoBehaviour
 {
  
     public GUISkin skin;
  
     private float gldepth = -0.5f;
     private float startTime = 0.1f;
     //
     public Texture racertexture;
     public Texture pausebtn;
     public Material mat;
  
     private long tris = 0;
     private long verts = 0;
     private float savedTimeScale;
     // private SepiaToneEffect pauseFilter;
  
     private bool showfps;
     private bool showtris;
     private bool showvtx;
     private bool showfpsgraph;
  
     public Color lowFPSColor = Color.red;
     public Color highFPSColor = Color.green;
  
     public int lowFPS = 30;
     public int highFPS = 50;
  
     public GameObject start;
  
     public string url = "unity.html";
  
     public Color statColor = Color.yellow;
  
     public string[] Instructions= {
         "NonLinearGames",
         "Presents Crazy Racer",
         "Change Steering by Tablet or Joystick",
         "with the Two Icons (Top Right)",
         "If your car gets stuck press the Icon ",
         "Next to the  Speedo (Top Left) ",
         "Levels will open after you complete ",
          "the previous level faster than a set time. "};
         
         
         public Texture[] crediticons;
  
     public enum Page {
         None,Main,Options,Instructions
     }
  
     private Page currentPage;
  
     private float[] fpsarray;
     private float fps;
  
     private int toolbarInt = 0;
     private string[]  toolbarstrings =  {"Audio","Unused","Stats","System"};
  
  
     void Start() {
         fpsarray = new float[Screen.width];
         Time.timeScale = 1;
         // pauseFilter = Camera.main.GetComponent<SepiaToneEffect>();
         // PauseGame();
     }
  
     void OnPostRender() {
         if (showfpsgraph && mat != null) {
             GL.PushMatrix ();
             GL.LoadPixelMatrix();
             for (var i = 0; i < mat.passCount; ++i)
             {
                 mat.SetPass(i);
                 GL.Begin( GL.LINES );
                 for (int x=0; x < fpsarray.Length; ++x) {
                     GL.Vertex3(x, fpsarray[x], gldepth);
                 }
             GL.End();
             }
             GL.PopMatrix();
             ScrollFPS();
         }
     }
  
     void ScrollFPS() {
         for (int x = 1; x < fpsarray.Length; ++x) {
             fpsarray[x-1]=fpsarray[x];
         }
         if (fps < 1000) {
             fpsarray[fpsarray.Length - 1]=fps;
         }
     }
  
     static bool IsDashboard() {
         return Application.platform == RuntimePlatform.OSXDashboardPlayer;
     }
  
     static bool IsBrowser() {
         return (Application.platform == RuntimePlatform.WindowsWebPlayer ||
             Application.platform == RuntimePlatform.OSXWebPlayer);
     }
  
     void LateUpdate () {
         if (showfps || showfpsgraph) {
             FPSUpdate();
         }
        
          if (Input.GetKeyDown("escape")) 
         
                 
         {
                     switch (currentPage) 
             {
                      
                 case Page.None: 
                     PauseGame(); 
                     break;
  
                 case Page.Main: 
                     if (!IsBeginning()) 
                         UnPauseGame(); 
                     break;
  
                 default: 
                     currentPage = Page.Main;
                     break;
            
                 }
         }
     }
  
     void OnGUI () {
         if (GUI.Button(new Rect(180,0,50,50),pausebtn))
             {
                     switch (currentPage) 
             {
                      
                 case Page.None: 
                     PauseGame(); 
                     break;
  
                 case Page.Main: 
                     if (!IsBeginning()) 
                         UnPauseGame(); 
                     break;
  
                 default: 
                     currentPage = Page.Main;
                     break;
            
                 }
         }
     
 
 
 
 
 
         
    //  GUI.Box(new Rect(0,0,Screen.width,Screen.height),racertexture);
         
         if (skin != null) {
             GUI.skin = skin;
         }
         ShowStatNums();
         ShowLegal();
         if (IsGamePaused()) {
             GUI.color = statColor;
             switch (currentPage) {
                 case Page.Main: MainPauseMenu(); break;
                 case Page.Options: ShowToolbar(); break;
                 case Page.Instructions: ShowInstructions(); break;
             }
         }   
     }
  
     void ShowLegal() {
         if (!IsLegal()) {
             GUI.Label(new Rect(Screen.width-100,Screen.height-20,90,20),
             "jdonavan.com");
         }
     }
  
     bool IsLegal() {
         return !IsBrowser() || 
         Application.absoluteURL.StartsWith("http://www.jdonavan.com/") ||
         Application.absoluteURL.StartsWith("http://jdonavan.com/");
  
     }
  
     void ShowToolbar() {
         BeginPage(300,300);
         toolbarInt = GUILayout.Toolbar (toolbarInt, toolbarstrings);
         switch (toolbarInt) {
             case 0: VolumeControl(); break;
             case 3: ShowDevice(); break;
             case 1: Qualities(); QualityControl(); break;
             case 2: StatControl(); break;
         }
         EndPage();
     }
  
     void ShowInstructions() {
         BeginPage(300,300);
         foreach(string credit in Instructions) {
             GUILayout.Label(credit);
         }
         foreach( Texture credit in crediticons) {
             GUILayout.Label(credit);
         }
         EndPage();
     }
  
     void ShowBackButton() {
         if (GUI.Button(new Rect(20, Screen.height - 50, 50, 20),"Back")) {
             currentPage = Page.Main;
         }
     }
  
     void ShowDevice() {
         GUILayout.Label("Unity player version "+Application.unityVersion);
         GUILayout.Label("Graphics: "+SystemInfo.graphicsDeviceName+" "+
         SystemInfo.graphicsMemorySize+"MB\n"+
         SystemInfo.graphicsDeviceVersion+"\n"+
         SystemInfo.graphicsDeviceVendor);
         GUILayout.Label("Shadows: "+SystemInfo.supportsShadows);
         GUILayout.Label("Image Effects: "+SystemInfo.supportsImageEffects);
         GUILayout.Label("Render Textures: "+SystemInfo.supportsRenderTextures);
     }
  
     void Qualities() {
         switch (QualitySettings.currentLevel) 
         {
             case QualityLevel.Fastest:
                 GUILayout.Label("Fastest");
                 break;
             case QualityLevel.Fast:
                 GUILayout.Label("Fast");
                 break;
             case QualityLevel.Simple:
                 GUILayout.Label("Simple");
                 break;
             case QualityLevel.Good:
                 GUILayout.Label("Good");
                 break;
             case QualityLevel.Beautiful:
                 GUILayout.Label("Beautiful");
                 break;
             case QualityLevel.Fantastic:
                 GUILayout.Label("Fantastic");
                 break;
         }
     }
  
     void QualityControl() {
         GUILayout.BeginHorizontal();
         if (GUILayout.Button("Decrease")) {
             QualitySettings.DecreaseLevel();
         }
         if (GUILayout.Button("Increase")) {
             QualitySettings.IncreaseLevel();
         }
         GUILayout.EndHorizontal();
     }
  
     void VolumeControl() {
         GUILayout.Label("Volume");
         AudioListener.volume = GUILayout.HorizontalSlider(AudioListener.volume, 0, 1);
     }
  
     void StatControl() {
         GUILayout.BeginHorizontal();
         showfps = GUILayout.Toggle(showfps,"FPS");
         showtris = GUILayout.Toggle(showtris,"Triangles");
         showvtx = GUILayout.Toggle(showvtx,"Vertices");
         showfpsgraph = GUILayout.Toggle(showfpsgraph,"FPS Graph");
         GUILayout.EndHorizontal();
     }
  
     void FPSUpdate() {
         float delta = Time.smoothDeltaTime;
             if (!IsGamePaused() && delta !=0.0) {
                 fps = 1 / delta;
             }
     }
  
     void ShowStatNums() {
         GUILayout.BeginArea( new Rect(Screen.width - 100, 10, 100, 200));
         if (showfps) {
             string fpsstring= fps.ToString ("#,##0 fps");
             GUI.color = Color.Lerp(lowFPSColor, highFPSColor,(fps-lowFPS)/(highFPS-lowFPS));
             GUILayout.Label (fpsstring);
         }
         if (showtris || showvtx) {
             GetObjectStats();
             GUI.color = statColor;
         }
         if (showtris) {
             GUILayout.Label (tris+"tri");
         }
         if (showvtx) {
             GUILayout.Label (verts+"vtx");
         }
         GUILayout.EndArea();
     }
  
     void BeginPage(int width, int height) {
         GUILayout.BeginArea( new Rect((Screen.width - width) / 2, (Screen.height - height) / 2, width, height));
     }
  
     void EndPage() {
         GUILayout.EndArea();
         if (currentPage != Page.Main) {
             ShowBackButton();
         }
     }
  
     bool IsBeginning() {
         return (Time.time < startTime);
     }
  
  
     void MainPauseMenu() {
         BeginPage(200,200);
         if (GUILayout.Button (IsBeginning() ? "Play" : "Continue")) {
             UnPauseGame();
  
         }
         if (GUILayout.Button ("Options")) {
             currentPage = Page.Options;
         }
         if (GUILayout.Button ("Instructions")) {
             currentPage = Page.Instructions;
         }
         if (IsBrowser() && !IsBeginning() && GUILayout.Button ("Restart")) {
             Application.OpenURL(url);
         }
         EndPage();
     }
  
     void GetObjectStats() {
         verts = 0;
         tris = 0;
         GameObject[] ob = FindObjectsOfType(typeof(GameObject)) as GameObject[];
         foreach (GameObject obj in ob) {
             GetObjectStats(obj);
         }
     }
  
     void GetObjectStats(GameObject obj) {
            Component[] filters;
         filters = obj.GetComponentsInChildren<MeshFilter>();
         foreach( MeshFilter f  in filters )
         {
             tris += f.sharedMesh.triangles.Length/3;
               verts += f.sharedMesh.vertexCount;
         }
     }
  
     void PauseGame() {
         savedTimeScale = Time.timeScale;
         Time.timeScale = 0;
         AudioListener.pause = true;
         // if (pauseFilter) 
         //     pauseFilter.enabled = true;
         currentPage = Page.Main;
     }
  
     void UnPauseGame() {
         Time.timeScale = savedTimeScale;
         AudioListener.pause = false;
         // if (pauseFilter) 
             // pauseFilter.enabled = false;
  
         currentPage = Page.None;
  
         if (IsBeginning() && start != null) {
             start.active = true;
         }
     }
  
     bool IsGamePaused() {
         return (Time.timeScale == 0);
     }
  
     void OnApplicationPause(bool pause) {
         if (IsGamePaused()) {
             AudioListener.pause = true;
         }
     }
 }



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
2
Best Answer

Answer by DESTRUKTORR · Apr 21, 2013 at 08:21 PM

QualityLevel is obsolete, in Unity. Simply change

 switch (QualitySettings.currentLevel) 
        {
             case QualityLevel.Fastest:
                GUILayout.Label("Fastest");
                break;
             case QualityLevel.Fast:
                GUILayout.Label("Fast");
                break;
             case QualityLevel.Simple:
                GUILayout.Label("Simple");
                break;
             case QualityLevel.Good:
                GUILayout.Label("Good");
                break;
             case QualityLevel.Beautiful:
                GUILayout.Label("Beautiful");
                break;
             case QualityLevel.Fantastic:
                GUILayout.Label("Fantastic");
                break;
         }

To

 switch (QualitySettings.GetQualityLevel()) 
        {
             case 0:
                GUILayout.Label("Fastest");
                break;
             case 1:
                GUILayout.Label("Fast");
                break;
             case 2:
                GUILayout.Label("Simple");
                break;
             case 3:
                GUILayout.Label("Good");
                break;
             case 4:
                GUILayout.Label("Beautiful");
                break;
             default:
                GUILayout.Label("Fantastic");
                break;
         }
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 javanoob · Apr 21, 2013 at 08:58 PM 0
Share

Thanks worked perfectly :)

avatar image DESTRUKTORR · Apr 21, 2013 at 09:02 PM 0
Share

No problem :)

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

12 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

Related Questions

Pause menu scripting help? 1 Answer

Hold the esc button for a pause menu 1 Answer

Pause Menu Text Not Rendering 0 Answers

Can you make a pause menu have mobile input? 0 Answers

GUI Buttons not working after scene transition 0 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