| | 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 Resolution", fileName = "ShadowResolutionControlCo |
| | 10 | | public class ShadowResolutionControlController : SpinBoxSettingsControlController |
| | 11 | | { |
| | 12 | | private UniversalRenderPipelineAsset lightweightRenderPipelineAsset = null; |
| | 13 | | private FieldInfo lwrpaShadowResolutionField = 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 | | lwrpaShadowResolutionField = lightweightRenderPipelineAsset.GetType().GetField("m_MainLightShadowmapResoluti |
| 2 | 25 | | } |
| | 26 | |
|
| 2 | 27 | | public override object GetStoredValue() { return (int)Mathf.Log((int)currentQualitySetting.shadowResolution, 2) |
| | 28 | |
|
| | 29 | | public override void UpdateSetting(object newValue) |
| | 30 | | { |
| 2 | 31 | | currentQualitySetting.shadowResolution = (UnityEngine.Rendering.Universal.ShadowResolution)(256 << (int)newV |
| | 32 | |
|
| 2 | 33 | | if (lightweightRenderPipelineAsset != null) |
| 2 | 34 | | lwrpaShadowResolutionField?.SetValue(lightweightRenderPipelineAsset, currentQualitySetting.shadowResolut |
| 2 | 35 | | } |
| | 36 | | } |
| | 37 | | } |