- Home /
Show current value of QualitySettings Anti Aliasing in script?
I want to be able to show the current anti alias setting on screen but there is no variable for antialiasing in the QualitySettings class.
Can someone tell me how to show the current antialising value (0X, 2X, 4X, 6X, 16X)?
Also, regarding antialiasing...
It's usually necessary to restart a game to set a new antialias level, but I see in the editor that when I set antialiasing higher or lower it updates immediately.
Will I have to require my end-users to restart if they change the antialias setting or does Unity do it on the fly?
Answer by qJake · Jun 08, 2010 at 10:17 PM
Currently, the only way to change the Anti-aliasing property at runtime is to manually set the QualitySettings.currentLevel property. Calling IncreaseLevel() or DecreaseLevel() will not work as these functions are instantaneous and don't change anti-aliasing settings. However, changing the currentLevel property can take some time, and may lag for a bit, since it does change anti-aliasing settings. The only way to manually set anti-aliasing levels is through the Quality editor in the Unity interface, you can't only set the AA level through scripting (you need to use Unity's quality levels). This is because changing the AA settings in-game is expensive, and can take time.
As for showing the level, just give each setting in the Quality editor a different value, and align those with the values that QualitySettings.currentValue returns.
Are there any changes in antialiasing controlling? I'm facing the same problem now.
To change AA you have to destroy your GL Context and create a new one, until Unity implements that properly I don't believe this is possible
Found this very old question. Actually, you don't need to do something special. Try to use smth like the code below. Your app will change the AA settings instantly. If QualitySettings.antiAliasing doesn't return expected result, just save the current AA property somewhere.
private static void SetAA(int _aa)
{
if (_aa == 0 || _aa == 2 || _aa == 4)
{
QualitySettings.antiAliasing = _aa;
}
else
Debug.LogWarning("Incorrect antialiasing setting: " + _aa.ToString());
}
Answer by VertexSoup · Feb 05, 2016 at 02:42 AM
I'd like to expand on @kirpigller comment with method that can be referenced directly from UI slider element. Slider should be set to work in range 0-4
public void ApplyAASetting(int aa)
{
int level = (int)Mathf.Pow(2, Mathf.Clamp(aa, 0, 4));
if (level <= 16)
{
QualitySettings.antiAliasing = (aa == 0) ? aa : level;
}
else
Debug.LogWarningFormat("Incorrect antialiasing (AA) setting: <color=red>{0}</color>", level.ToString());
}