< Summary

Class:DCL.SettingsControls.ShadowControlController
Assembly:SettingsControllers
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Settings/SettingsControllers/SpecificControllers/ShadowControlController.cs
Covered lines:16
Uncovered lines:1
Coverable lines:17
Total lines:50
Line coverage:94.1% (16 of 17)
Covered branches:0
Total branches:0

Metrics

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

File(s)

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

#LineLine coverage
 1using DCL.SettingsCommon;
 2using DCL.SettingsController;
 3using System.Reflection;
 4using UnityEngine;
 5using UnityEngine.Rendering;
 6using UnityEngine.Rendering.Universal;
 7
 8namespace DCL.SettingsControls
 9{
 10    [CreateAssetMenu(menuName = "Settings/Controllers/Controls/Shadow", fileName = "ShadowControlController")]
 11    public class ShadowControlController : ToggleSettingsControlController
 12    {
 13        private UniversalRenderPipelineAsset lightweightRenderPipelineAsset = null;
 14        private FieldInfo lwrpaShadowField = null;
 15
 16        public override void Initialize()
 17        {
 218            base.Initialize();
 19
 220            lightweightRenderPipelineAsset = GraphicsSettings.renderPipelineAsset as UniversalRenderPipelineAsset;
 21
 222            if (lightweightRenderPipelineAsset == null)
 023                return;
 24
 225            lwrpaShadowField = lightweightRenderPipelineAsset.GetType().GetField("m_MainLightShadowsSupported", BindingF
 226        }
 27
 228        public override object GetStoredValue() { return currentQualitySetting.shadows; }
 29
 30        public override void UpdateSetting(object newValue)
 31        {
 232            currentQualitySetting.shadows = (bool)newValue;
 33
 234            if (lightweightRenderPipelineAsset != null)
 235                lwrpaShadowField?.SetValue(lightweightRenderPipelineAsset, currentQualitySetting.shadows);
 36
 237            if (QualitySettingsReferences.i.environmentLight)
 38            {
 239                LightShadows shadowType = LightShadows.None;
 40
 241                if (currentQualitySetting.shadows)
 242                    shadowType = currentQualitySetting.shadows ? LightShadows.Soft : LightShadows.Hard;
 43
 244                QualitySettingsReferences.i.environmentLight.shadows = shadowType;
 45            }
 46
 247            CommonSettingsScriptableObjects.shadowsDisabled.Set(!currentQualitySetting.shadows);
 248        }
 49    }
 50}