| | 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/SoftShadows", fileName = "SoftShadowsControlController")] |
| | 10 | | public class SoftShadowsControlController : ToggleSettingsControlController |
| | 11 | | { |
| | 12 | | private UniversalRenderPipelineAsset lightweightRenderPipelineAsset = null; |
| | 13 | | private FieldInfo lwrpaSoftShadowField = 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 | | lwrpaSoftShadowField = lightweightRenderPipelineAsset.GetType().GetField("m_SoftShadowsSupported", BindingFl |
| 2 | 25 | | } |
| | 26 | |
|
| 2 | 27 | | public override object GetStoredValue() { return currentQualitySetting.softShadows; } |
| | 28 | |
|
| | 29 | | public override void UpdateSetting(object newValue) |
| | 30 | | { |
| 2 | 31 | | currentQualitySetting.softShadows = (bool)newValue; |
| | 32 | |
|
| 2 | 33 | | if (lightweightRenderPipelineAsset != null) |
| 2 | 34 | | lwrpaSoftShadowField?.SetValue(lightweightRenderPipelineAsset, currentQualitySetting.softShadows); |
| | 35 | |
|
| 2 | 36 | | if (SceneReferences.i.environmentLight) |
| | 37 | | { |
| 1 | 38 | | LightShadows shadowType = LightShadows.None; |
| | 39 | |
|
| 1 | 40 | | if (currentQualitySetting.shadows) |
| 1 | 41 | | shadowType = currentQualitySetting.softShadows ? LightShadows.Soft : LightShadows.Hard; |
| | 42 | |
|
| 1 | 43 | | SceneReferences.i.environmentLight.shadows = shadowType; |
| | 44 | | } |
| 2 | 45 | | } |
| | 46 | | } |
| | 47 | | } |