< Summary

Class:DCL.SettingsCommon.SettingsControllers.SpecificControllers.SSAOControlController
Assembly:SettingsControllers
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Settings/SettingsControllers/SpecificControllers/SSAOControlController.cs
Covered lines:19
Uncovered lines:9
Coverable lines:28
Total lines:69
Line coverage:67.8% (19 of 28)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Initialize()0%110100%
GetStoredValue()0%110100%
UpdateSetting(...)0%9.455043.75%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Settings/SettingsControllers/SpecificControllers/SSAOControlController.cs

#LineLine coverage
 1using System.Collections;
 2using System.Reflection;
 3using DCL.SettingsCommon.SettingsControllers.BaseControllers;
 4using UnityEngine;
 5using UnityEngine.Rendering;
 6using UnityEngine.Rendering.Universal;
 7
 8namespace DCL.SettingsCommon.SettingsControllers.SpecificControllers
 9{
 10    [CreateAssetMenu(menuName = "Settings/Controllers/Controls/SSAO Controller", fileName = "SSAOControlController")]
 11    public class SSAOControlController : SpinBoxSettingsControlController
 12    {
 13        private UniversalRenderPipelineAsset urpAsset = null;
 14        private ScriptableRendererFeature ssaoFeature;
 15
 16        private object settings;
 17        private FieldInfo sourceField;
 18        private FieldInfo downsampleField;
 19
 20        public override void Initialize()
 21        {
 122            base.Initialize();
 23
 124            urpAsset = GraphicsSettings.renderPipelineAsset as UniversalRenderPipelineAsset;
 25
 126            ScriptableRenderer forwardRenderer = urpAsset.GetRenderer(0) as ScriptableRenderer;
 127            var featuresField = typeof(ScriptableRenderer).GetField("m_RendererFeatures", BindingFlags.NonPublic | Bindi
 28
 129            IList features = featuresField.GetValue(forwardRenderer) as IList;
 130            ssaoFeature = features[0] as ScriptableRendererFeature;
 31
 132            FieldInfo settingsField = ssaoFeature.GetType().GetField("m_Settings", BindingFlags.NonPublic | BindingFlags
 133            settings = settingsField.GetValue(ssaoFeature);
 34
 135            sourceField = settings.GetType().GetField("Source", BindingFlags.NonPublic | BindingFlags.Instance);
 136            downsampleField = settings.GetType().GetField("Downsample", BindingFlags.NonPublic | BindingFlags.Instance);
 137        }
 38
 139        public override object GetStoredValue() { return currentQualitySetting.ssaoQuality; }
 40
 41        public override void UpdateSetting(object newValue)
 42        {
 143            int value = (int)newValue;
 44            switch ( value )
 45            {
 46                case (int)QualitySettings.SSAOQualityLevel.OFF:
 047                    ssaoFeature.SetActive(false);
 048                    break;
 49                case (int)QualitySettings.SSAOQualityLevel.LOW:
 050                    ssaoFeature.SetActive(true);
 051                    sourceField.SetValue(settings, 0);
 052                    downsampleField.SetValue(settings, true);
 053                    break;
 54                case (int)QualitySettings.SSAOQualityLevel.MID:
 155                    ssaoFeature.SetActive(true);
 156                    sourceField.SetValue(settings, 1);
 157                    downsampleField.SetValue(settings, true);
 158                    break;
 59                case (int)QualitySettings.SSAOQualityLevel.HIGH:
 060                    ssaoFeature.SetActive(true);
 061                    sourceField.SetValue(settings, 1);
 062                    downsampleField.SetValue(settings, false);
 63                    break;
 64            }
 65
 166            currentQualitySetting.ssaoQuality = (QualitySettings.SSAOQualityLevel)value;
 167        }
 68    }
 69}