C# Accessing Quality Settings Preset Values

Hi everyone, I want to access a specific value of a preset like Fantastic’s Anti-Aliasing value and I want access it even if Fantastic isn’t being used currently. How exactly would I do that?

Here’s a C# example of how to change the AA settings using a Horizontal Slider. Not too in depth, but should get you started.

using UnityEngine;
using System.Collections;

public class Example : MonoBehaviour 
{
	float aa = 0;
	
	void Update()
	{
		if(QualitySettings.antiAliasing != aa)
		{
			QualitySettings.antiAliasing = (int)aa;
			print (QualitySettings.antiAliasing);
		}
	}
	
	void OnGUI()
	{
		aa = GUI.HorizontalSlider(new Rect(0, 0, 256, 32), aa, 0, 8);	
	}
}

Here’s another example of how to change the actual quality preset. In this example I’ll also use a Horizontal Slider.

using UnityEngine;
using System.Collections;

public class Example : MonoBehaviour 
{
	int level;
	string label;
	
	void Awake()
	{
		level = QualitySettings.GetQualityLevel();	
	}
	
	void Update()
	{
		if(QualitySettings.GetQualityLevel() != level)
		{
			QualitySettings.SetQualityLevel(level);
		}
		
		if(label != "Quality Level = "+QualitySettings.GetQualityLevel().ToString())
			label = "Quality Level = "+QualitySettings.GetQualityLevel().ToString();
	}
	
	void OnGUI()
	{
		level = (int)GUI.HorizontalSlider(new Rect(0, 0, 256, 32), level, 0, 5);
		GUI.Label(new Rect(0, 64, 256, 32), label);
	}
}

Good question. I don’t know if this is the best solution, but you could do something like this:

  1. QualitySettings.SetQualityLevel, maybe with false.
  2. Get values from QualitySettings.
  3. Set QualitySettings back to the original one used.