I’m building a “settings” menu for players and I want to allow hem to adjust certain things like resolution, texture quality etc. I see Unity list quality in a ranking system inthe editor. How do I let players adjust these settings in app? Can I do this via programmatically? User clicks button a for example and changes texture from good to ultra for example?
So, I haven’t delved in to this myself yet, but there is an API:
If you want to allow the user to choose one of the existing quality settings, it looks like you can use the QualitySettings.names array to populate a drop-down menu or something. Then you can pass the selected index into SetQualityLevel.
Additionally, it looks like you can set each item individually for a custom quality level.
I got this so far. Is there any thing else I would need for 2d games?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Core_Visual_Settings : MonoBehaviour
{
public Dropdown _dlScreenResolutions;
public Dropdown _dlAntiAliasing;
public Dropdown _dlQuality;
public Dropdown _dlAnisotropic;
public Toggle _isFullScreen;
private Resolution[] resolutions;
private int _Quality;
private int _AntiAliasing;
void Start()
{
//Screen Resolution
List<string> options = new List<string>();
int currentresolution = 0;
resolutions = Screen.resolutions;
_dlScreenResolutions.ClearOptions();
for(int i = 0; i < resolutions.Length; i++)
{
string option = resolutions[i].width.ToString() + " x " + resolutions[i].height.ToString();
options.Add(option);
if(resolutions[i].width == Screen.currentResolution.width && resolutions[i].height == Screen.currentResolution.height)
{
currentresolution = i;
}
}
_dlScreenResolutions.AddOptions(options);
_dlScreenResolutions.value = currentresolution;
_dlScreenResolutions.RefreshShownValue();
//Anti Aliasing
_AntiAliasing = QualitySettings.antiAliasing;
_dlAntiAliasing.value = _AntiAliasing;
_dlAntiAliasing.RefreshShownValue();
//Quality Level
_Quality = QualitySettings.GetQualityLevel();
_dlQuality.value = _Quality;
_dlQuality.RefreshShownValue();
}
public void Set_Screen_Resolution(int resolutionindex)
{
Resolution resolution = resolutions[resolutionindex];
Screen.SetResolution(resolution.width, resolution.height, Screen.fullScreen);
}
public void Set_Full_screen()
{
Screen.fullScreen = _isFullScreen.isOn;
}
public void Set_Anti_Aliasing()
{
string Selected = _dlAntiAliasing.options[_dlAntiAliasing.value].text;
switch (Selected)
{
case "Off":
QualitySettings.antiAliasing = 0;
break;
case "On":
QualitySettings.antiAliasing = 1;
break;
case "2x":
QualitySettings.antiAliasing = 2;
break;
case "4x":
QualitySettings.antiAliasing = 3;
break;
default:
QualitySettings.antiAliasing = 0;
break;
}
_dlAntiAliasing.RefreshShownValue();
}
public void Set_Quality()
{
int Qualityindex = _dlQuality.value;
QualitySettings.SetQualityLevel(Qualityindex);
_dlQuality.RefreshShownValue();
}
public void Set_Anisotropic_Texturing()
{
string Selected = _dlAntiAliasing.options[_dlAntiAliasing.value].text;
switch(Selected)
{
case "Disabled":
QualitySettings.anisotropicFiltering = AnisotropicFiltering.Disable;
break;
case "Per Texture":
QualitySettings.anisotropicFiltering = AnisotropicFiltering.Enable;
break;
case "Forced On":
QualitySettings.anisotropicFiltering = AnisotropicFiltering.ForceEnable;
break;
}
}
}
I don’t suppose this is part of “Quality settings” in Unity, but you might want to include settings for whatever post-processing filters that you are using as well. If you have any settings that are only “nice to have” bu might have a significant performance impact.
We only make 2d games. What settings post processing to you suggest we have/add?
No need to add them if you don’t need any.
I just meant that if you already had post-processing effects then you could add those options in your graphics settings screen.