Author Topic: [Solved]Quality Settings  (Read 7874 times)

webik150

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 36
    • View Profile
[Solved]Quality Settings
« on: April 20, 2013, 02:21:12 AM »
Hey. I'm trying to make a POPUP menu, where you can change Quality Settings. I don't understand the
  1. QualitySettings.SetQualityLevel(i, true)

This is my code: (I have just edited the code from tutorial.)
  1. using UnityEngine;
  2. [ExecuteInEditMode]
  3. [RequireComponent(typeof(UIWidget))]
  4. [AddComponentMenu("NGUI/Examples/Set Color on Selection")]
  5. public class SetQualityLevel : MonoBehaviour{
  6.    UIWidget mWidget;
  7.    void OnSelectionChange (string val){
  8.       if (mWidget == null) mWidget = GetComponent<UIWidget>();
  9.       switch (val)
  10.       {
  11.          case "Lowest":   QualitySettings.SetQualityLevel(Lowest, true);   break;
  12.          case "Lower":   QualitySettings.SetQualityLevel(Lower, true);      break;
  13.          case "Low":   QualitySettings.SetQualityLevel(Low, true);   break;
  14.          case "Normal":   QualitySettings.SetQualityLevel(Normal, true);      break;
  15.          case "High":   QualitySettings.SetQualityLevel(High, true);   break;
  16.          case "Ultra":   QualitySettings.SetQualityLevel(Ultra, true);      break;
  17.       }
  18.    }
  19. }

The error says, that the Lowest, Lower, Low... doesn't exist in current context.
Can somebody please help me?
« Last Edit: April 21, 2013, 02:27:52 PM by webik150 »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Quality Settings
« Reply #1 on: April 20, 2013, 09:05:02 AM »
You didn't define them anywhere, so how can it find them?

webik150

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 36
    • View Profile
Re: Quality Settings
« Reply #2 on: April 20, 2013, 10:38:05 AM »
Yeah. I realized that too, but how can I define them and where?

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Quality Settings
« Reply #3 on: April 20, 2013, 05:58:36 PM »
In the unity quality settings, I would guess.

webik150

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 36
    • View Profile
Re: Quality Settings
« Reply #4 on: April 21, 2013, 01:33:40 AM »
Well, I have set up the unity quality settings, but it's still the same. I also tried this:
  1. using UnityEngine;
  2. [ExecuteInEditMode]
  3. [RequireComponent(typeof(UIWidget))]
  4. [AddComponentMenu("NGUI/Examples/Set Color on Selection")]
  5. public class SetQualityLevel : MonoBehaviour{
  6.    UIWidget mWidget;
  7.    void OnSelectionChange (string val){
  8.       if (mWidget == null) mWidget = GetComponent<UIWidget>();
  9.       switch (val)
  10.       {
  11.          case "Lowest":   QualitySettings.SetQualityLevel(1, true);   break;
  12.          case "Lower":   QualitySettings.SetQualityLevel(2, true);      break;
  13.          case "Low":   QualitySettings.SetQualityLevel(3, true);   break;
  14.          case "Normal":   QualitySettings.SetQualityLevel(4, true);      break;
  15.          case "High":   QualitySettings.SetQualityLevel(5, true);   break;
  16.          case "Ultra":   QualitySettings.SetQualityLevel(6, true);      break;
  17.       }
  18.    }
  19. }
and putting the Lowest, Lower into "".
The version with numbers doesn't show any error, but it doesn't work. (Tried in both, Unity Editor and Stadnalone)

EDIT: My quality settings are in pic.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Quality Settings
« Reply #5 on: April 21, 2013, 06:32:13 AM »
The code looks right. How are you calling the method?
Also, why are you caching the widget if you're not using it?

webik150

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 36
    • View Profile
Re: Quality Settings
« Reply #6 on: April 21, 2013, 09:42:47 AM »
OnSelectionChange
And I don't really know. As I said, I just copied the code from the tutorial and edited it a bit.

Zarack

  • Guest
Re: Quality Settings
« Reply #7 on: April 21, 2013, 11:41:02 AM »
I just had to figure this out for my project. I'll share what I came up with.

  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. public class GraphicsQuality : MonoBehaviour {
  6.        
  7.         public List<string> qualities;
  8.         public int graphicsInt;
  9.        
  10.         // Use this for initialization
  11.         void Start () {
  12.                 foreach(string item in QualitySettings.names){
  13.                         qualities.Add(item);
  14.                 }
  15.         }
  16.        
  17.         // Update is called once per frame
  18.         void Update () {
  19.        
  20.         }
  21.        
  22.         public void OnSelectionChange(string mSelectedItem) {
  23.                 if(qualities.Contains(mSelectedItem)) {
  24.                         Debug.Log("Changing Quality");
  25.                         graphicsInt = qualities.IndexOf(mSelectedItem);
  26.                         QualitySettings.SetQualityLevel(graphicsInt, true);
  27.                 }
  28.         }
  29. }

and set it up in the hierarchy as such:



I just threw the GraphicsQuality script on a salient Label and set it as the event receiver for the popup list (call OnSelectionChange). Make sure the options you want available match up!

Hope this helps.

Zarack

  • Guest
Re: Quality Settings
« Reply #8 on: April 21, 2013, 11:49:45 AM »
Just for more clarity I took this snapshot.

The 'Label - Graphics Quality' has the GraphicsQuality script attached to it.


webik150

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 36
    • View Profile
Re: Quality Settings
« Reply #9 on: April 21, 2013, 02:00:36 PM »
Yay! Thanks a lot Zarack. This really helped.