| | 1 | | using DCL.SettingsCommon.SettingsControllers.BaseControllers; |
| | 2 | | using UnityEngine; |
| | 3 | | using UnityEngine.Rendering; |
| | 4 | | using UnityEngine.Rendering.Universal; |
| | 5 | |
|
| | 6 | | namespace DCL.SettingsCommon.SettingsControllers.SpecificControllers |
| | 7 | | { |
| | 8 | |
|
| | 9 | | [CreateAssetMenu(menuName = "Settings/Controllers/Controls/AntiAliasing", fileName = "AntiAliasingControlController" |
| | 10 | | public class AntiAliasingControlController : SliderSettingsControlController |
| | 11 | | { |
| | 12 | | public const string TEXT_OFF = "OFF"; |
| | 13 | |
|
| | 14 | | private UniversalRenderPipelineAsset lightweightRenderPipelineAsset = null; |
| | 15 | |
|
| | 16 | | public override void Initialize() |
| | 17 | | { |
| 2 | 18 | | base.Initialize(); |
| | 19 | |
|
| 2 | 20 | | if (lightweightRenderPipelineAsset == null) |
| 2 | 21 | | lightweightRenderPipelineAsset = GraphicsSettings.renderPipelineAsset as UniversalRenderPipelineAsset; |
| 2 | 22 | | } |
| | 23 | |
|
| | 24 | | public override object GetStoredValue() |
| | 25 | | { |
| 2 | 26 | | float antiAliasingValue = |
| | 27 | | currentQualitySetting.antiAliasing == MsaaQuality.Disabled |
| | 28 | | ? 0 |
| | 29 | | : ((int)currentQualitySetting.antiAliasing >> 2) + 1; |
| | 30 | |
|
| 2 | 31 | | return antiAliasingValue; |
| | 32 | | } |
| | 33 | |
|
| | 34 | | public override void UpdateSetting(object newValue) |
| | 35 | | { |
| 2 | 36 | | float newFloatValue = (float)newValue; |
| | 37 | |
|
| 2 | 38 | | int antiAliasingValue = 1 << (int)newFloatValue; |
| 2 | 39 | | currentQualitySetting.antiAliasing = (MsaaQuality)antiAliasingValue; |
| | 40 | |
|
| 2 | 41 | | if (lightweightRenderPipelineAsset != null) |
| 2 | 42 | | lightweightRenderPipelineAsset.msaaSampleCount = antiAliasingValue; |
| | 43 | |
|
| 2 | 44 | | if (newFloatValue == 0) |
| 1 | 45 | | RaiseOnIndicatorLabelChange(TEXT_OFF); |
| | 46 | | else |
| 1 | 47 | | RaiseOnIndicatorLabelChange(antiAliasingValue.ToString("0x")); |
| 1 | 48 | | } |
| | 49 | | } |
| | 50 | | } |