| | 1 | | using System.Reflection; |
| | 2 | | using DCL.SettingsCommon.SettingsControllers.BaseControllers; |
| | 3 | | using UnityEngine; |
| | 4 | | using UnityEngine.Rendering; |
| | 5 | | using UnityEngine.Rendering.Universal; |
| | 6 | |
|
| | 7 | | namespace DCL.SettingsCommon.SettingsControllers.SpecificControllers |
| | 8 | | { |
| | 9 | | [CreateAssetMenu(menuName = "Settings/Controllers/Controls/Shadow", fileName = "ShadowControlController")] |
| | 10 | | public class ShadowControlController : ToggleSettingsControlController |
| | 11 | | { |
| | 12 | | private UniversalRenderPipelineAsset lightweightRenderPipelineAsset = null; |
| | 13 | | private FieldInfo lwrpaShadowField = null; |
| | 14 | |
|
| | 15 | | public override void Initialize() |
| | 16 | | { |
| 2 | 17 | | base.Initialize(); |
| | 18 | |
|
| 2 | 19 | | lightweightRenderPipelineAsset = GraphicsSettings.renderPipelineAsset as UniversalRenderPipelineAsset; |
| | 20 | |
|
| 2 | 21 | | if (lightweightRenderPipelineAsset == null) |
| 0 | 22 | | return; |
| | 23 | |
|
| 2 | 24 | | lwrpaShadowField = lightweightRenderPipelineAsset.GetType().GetField("m_MainLightShadowsSupported", BindingF |
| 2 | 25 | | } |
| | 26 | |
|
| 2 | 27 | | public override object GetStoredValue() { return currentQualitySetting.shadows; } |
| | 28 | |
|
| | 29 | | public override void UpdateSetting(object newValue) |
| | 30 | | { |
| 2 | 31 | | currentQualitySetting.shadows = (bool)newValue; |
| | 32 | |
|
| 2 | 33 | | if (lightweightRenderPipelineAsset != null) |
| 2 | 34 | | lwrpaShadowField?.SetValue(lightweightRenderPipelineAsset, currentQualitySetting.shadows); |
| | 35 | |
|
| 2 | 36 | | if (SceneReferences.i.environmentLight) |
| | 37 | | { |
| 1 | 38 | | LightShadows shadowType = LightShadows.None; |
| | 39 | |
|
| 1 | 40 | | if (currentQualitySetting.shadows) |
| 1 | 41 | | shadowType = currentQualitySetting.shadows ? LightShadows.Soft : LightShadows.Hard; |
| | 42 | |
|
| 1 | 43 | | SceneReferences.i.environmentLight.shadows = shadowType; |
| | 44 | | } |
| | 45 | |
|
| 2 | 46 | | CommonSettingsScriptableObjects.shadowsDisabled.Set(!currentQualitySetting.shadows); |
| 2 | 47 | | } |
| | 48 | | } |
| | 49 | | } |