- Home /
How can I toggle shadows in scripting?
I want to be able to turn shadows on and off in scripting. Is there anyway of doing this? I have looked in quality settings, but there is no global option. Also, where is the scripting equivalent of texture quality. I want users to be able to toggle between eighth res, quater res, half res and full res? Any comments will be appreciated Stormy102
http://docs.unity3d.com/ScriptReference/Light-shadows.html and probably something more usefull at http://answers.unity3d.com/questions/671314/disable-shadows.html
Thanks. But I want it as a global option, not for each scene.
I don't think its possible, is it? Otherwise there would be an option in the docs.
Stormy102
Answer by tanoshimi · Sep 30, 2014 at 01:24 PM
Although shadows on/off is not an exposed scriptable quality setting, you could create two custom quality settings - one with shadows and one without, and switch between them using QualitySettings.SetQualityLevel.
Either that or, depending on how many lights you have in the scene, you could simply loop through them all and set their shadows property to LightShadows.None.
Answer by Tanshaydar · Sep 30, 2014 at 01:24 PM
There is no global setting 'just to disable' shadows. That's hardcoded in Unity. However, you can create two identical quality settings with one shadows enabled and one disabled, and switch between two at runtime with QualitySettings.SetQualityLevel
This won't work if you have quality settings differently to be selected by user though. More information can be found here: http://docs.unity3d.com/ScriptReference/QualitySettings.html