Toggle threw Quality Settings with Keyboard key?

hey! so i know how i can change the quality settings during runtime:

public void IncreaseLevel () {
		QualitySettings.IncreaseLevel(true);

	}
	public void DecreaseLevel () {

		QualitySettings.DecreaseLevel(true);

	}

but how can i do something like:

if (Input.GetKeyDown(KeyCode.Alpha7)){
			QualitySettings.SetQualityLevel(next)
		}

so that it goes back to quality level 1 when its at 6 and i press the AlphaKey7 again?

While there doesn’t appear to be a predefined integer for the number of Quality Levels, that doesn’t mean the quantity can’t still be determined.

QualitySettings.names will provide an array containing the total number of Quality Levels, so that can be used to snag the total count. Actually cycling through them would be simple enough, however, since you’re already doing much of that:

// C#
int qualityLevelCount;

void Start()
{
	qualityLevelCount = QualitySettings.names.Length;
}

if(Input.GetKeyDown(KeyCode.Alpha7))
{
	int currentLevel = QualitySettings.GetQualityLevel();
	QualitySettings.SetQualityLevel((currentLevel + 1) % qualityLevelCount, true);
}