How do I change QualitySetting for my platform from code?

If I set QualitySettings.antiAliasing, then it sets value on quality level that was selected with a mouse, i.e. grey line - “Simple” in the image below:

alt text

How do I set QualitySettings.antiAliasing for level that is selected as a Default value for some platform, i.e. green checkbox - “Fastest”?

2 Answers

2

I believe you need to change the quality level first as changing anti-aliasing through code changes it for the currently selected quality setting. You can change it with QualitySettings.SetQualityLevel, then set the anti-aliasing. Unfortunately I do not know how you can get hold of which level is the default level through code.

Exactly - there is no way to know which is default level through code. Otherwise, yes I could accomplish that ;) so API is incomplete as far as I'm aware.

–

Most likely because it is a setting only necessary at edit time and QualitySettings is a runtime class. There is no QualitySettingsEditor class (actually there is but it is a private class only available to Unity) to edit the default settings through.

–

@GameVortex, exactly again :) I need it for Edit time, to suppress "AA is enabled" warning when building AssetBundles...

–

Good to know. I guess it's even possible to read it using SerializedObject and iterate through properties. Although I hoped I missed something and there is API for that :) I'll just hack something for now until they fix issues related to these QualitySettings

–

Well, theoretically yes, if you could ever get the reference to the serializedObject at all. QualitySettings is a static class and never returns any object you could use reflection on.

–

http://docs.unity3d.com/ScriptReference/QualitySettings.html

http://docs.unity3d.com/Manual/PlatformDependentCompilation.html

Check out these links. It should be everything you need for this.

This is not helpful. See the answer by @GameVortex. We both agree that API is incomplete, so no - not everything I need is in the links that you have provided.

–

What's missing except ability to determine the default?

–

When you can not get/set default you can not set it on the right one, when building AssetBundles (QualitySettings have impact on building of AssetBundles, unfotunatelly). I guess you're right - QualitySettings is designed for runtime, but that's exactly my point there is no API in editor to do what I need.

–

Indeed it appears that the editor quality settings are just something of pre-defined macros. Check out this extract > When building a player quality levels > that are not used for that platform > are stripped. You should not expect a > given quality setting to be at a given > index. It's best to query the > available quality settings and use the > returned index.

–

Unity is confused by this thing itself :) If you uncheck one of the quality settings from a list and build Standalone application, then you're default selection will be shifted by one ;) ...also "mouse selection" (i.e. grey line) is used as a default for Standalone build, which baffles me...

–