- Home /
How can I change the shadow-resolutions property without having to increase or decrease quality level?
Now... I know this has been asked before, but NOBODY really got an actual answer to this.
Unity doesn't give me the variables for the quality settings for shadows quality (like soft, hard, soft+hard, shadow resolution etc...). So I thought I cheat by gathering all light sources of a scene with Object.FindObjectsOfType and change the shadow resolutions for every light in the scene. But I got trolled again (it doesn't exist for the Light class either).
using UnityEngine;
using System.Collections;
public class ShadowsQuality : MonoBehaviour {
public static int shadowsQualityLevel;
private enum g_ShaowsQualityLevels {Low, Medium, High}
private Light[] allLightSources;
void Start () {
allLightSources = Object.FindObjectsOfType(typeof(Light)) as Light[];
}
void Update () {
switch(shadowsQualityLevel){
case 0:
foreach(Light lights in allLightSources){
lights.shadows = LightShadows.Hard;
//WHERE IS THE SHADOWS RESOLUTION VARIABLE?!
}
break;
case 1:
foreach(Light lights in allLightSources){
lights.shadows = LightShadows.Soft;
}
break;
case 2:
foreach(Light lights in allLightSources){
lights.shadows = LightShadows.Soft;
}
break;
}
}
}
Does anybody know how I am supposed to change such an important setting from a script without having to switch between entire quality levels defined in the Inspector? I know that the Slender: The Arrival team made it somehow (you can customize every single setting in that game, from AA and AF to global shadows quality etc etc etc...).
It would be pathetic to make the users not be able to change the single settings and force them to switch between one global quality state (like, for example GRAPHICS: On/Off or GRAPHICS: Low, Medium, High XD).
Answer by Benproductions1 · Jul 28, 2013 at 11:15 PM
Hello,
Simple answer: You can't. For some odd reason Unity does not allow you to change certain quality settings at runtime.
Here is a workaround: http://forum.unity3d.com/threads/182101-Enable-or-disable-shadows-and-set-shadow-quality-at-runtime
Hope this helps,
Benproductions1
Ps: Yes I found the answer through a google search :P
thanks for your answer, I feel a bit weird though. I didn't expect this from Unity. Now I have to do that painful painful painful workaround with over 9000 quality levels (each of those depending on the other settings of the user -.-, like shadows high + textures low, shadows medium + textures high, etc etc etc...)
It's not as bad as you think. $$anonymous$$ost quality settings are accessible from scripts. See this for all settings.
well but how should I proceed then? create quality levels for shadows = low + textures = high, shadows = medium + textures = high, etc etc etc... Are the vsync and texture settings applied then (through QualitySettings.vSyncCount etc...) even if I switch between all those quality levels?
Just have all the non-accessible quality settings as separate quality levels. Then when you change those, you just reapply any other custom settings.
Thank you a lot for your help. At least I know what I have to do now :)
Answer by Eideren · Aug 30, 2015 at 05:56 PM
If you came here for a simple solution, there is none. This feature has been posted on the feedback page, you might want to vote on that so that it hopefully gets implemented : http://feedback.unity3d.com/suggestions/allow-shadow-quality-to-be-changed-at-runtime-via-scripts
Light.shadowResolution was added for this: https://docs.unity3d.com/540/Documentation/ScriptReference/Light-shadowResolution.html