From a53661640dc26e3f8b7913c73d8933d28bfb0f7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alptu=C4=9F=20C=C4=B1r=C4=B1t?= Date: Thu, 19 Sep 2024 17:53:05 +0300 Subject: [PATCH] fix for all cases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Alptuğ Cırıt --- Assets/AWSIM/Scripts/UI/GraphicsSettings.cs | 123 +++++++++++--------- 1 file changed, 70 insertions(+), 53 deletions(-) diff --git a/Assets/AWSIM/Scripts/UI/GraphicsSettings.cs b/Assets/AWSIM/Scripts/UI/GraphicsSettings.cs index df88c6359..d12f27be5 100644 --- a/Assets/AWSIM/Scripts/UI/GraphicsSettings.cs +++ b/Assets/AWSIM/Scripts/UI/GraphicsSettings.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.Rendering; @@ -141,27 +140,33 @@ private void GraphicsLowQuality() // update camera parameters foreach (var cam in _cameraObjectsList) { - cam.TryGetComponent(out var cameraData); - cam.TryGetComponent(out var cameraVolume); - var cameraVolumeProfile = cameraVolume.profile; + if (cam) + { + cam.TryGetComponent(out var cameraData); + cam.TryGetComponent(out var cameraVolume); + var cameraVolumeProfile = cameraVolume.profile; - cameraData.antialiasing = AntialiasingMode.None; - cameraData.renderPostProcessing = false; - cameraData.renderShadows = false; - cameraData.allowHDROutput = false; + cameraData.antialiasing = AntialiasingMode.None; + cameraData.renderPostProcessing = false; + cameraData.renderShadows = false; + cameraData.allowHDROutput = false; - if (cameraVolumeProfile.TryGet(out Bloom bloom)) - { - bloom.active = false; - } + if (cameraVolumeProfile.TryGet(out Bloom bloom)) + { + bloom.active = false; + } - if (cameraVolumeProfile.TryGet(out Tonemapping tonemapping)) - { - tonemapping.active = false; + if (cameraVolumeProfile.TryGet(out Tonemapping tonemapping)) + { + tonemapping.active = false; + } } } - _sunSource.shadows = LightShadows.Hard; + if (_sunSource) + { + _sunSource.shadows = LightShadows.Hard; + } } private void GraphicsMediumQuality() @@ -173,29 +178,35 @@ private void GraphicsMediumQuality() // update camera and volume parameters foreach (var cam in _cameraObjectsList) { - cam.TryGetComponent(out var cameraData); - cam.TryGetComponent(out var cameraVolume); - var cameraVolumeProfile = cameraVolume.profile; + if (cam) + { + cam.TryGetComponent(out var cameraData); + cam.TryGetComponent(out var cameraVolume); + var cameraVolumeProfile = cameraVolume.profile; - cameraData.antialiasing = AntialiasingMode.FastApproximateAntialiasing; - cameraData.antialiasingQuality = AntialiasingQuality.Medium; - cameraData.renderPostProcessing = true; - cameraData.renderShadows = true; - cameraData.allowHDROutput = false; + cameraData.antialiasing = AntialiasingMode.FastApproximateAntialiasing; + cameraData.antialiasingQuality = AntialiasingQuality.Medium; + cameraData.renderPostProcessing = true; + cameraData.renderShadows = true; + cameraData.allowHDROutput = false; - if (cameraVolumeProfile.TryGet(out Bloom bloom)) - { - bloom.active = false; - bloom.intensity.value = 0.25f; - } + if (cameraVolumeProfile.TryGet(out Bloom bloom)) + { + bloom.active = false; + bloom.intensity.value = 0.25f; + } - if (cameraVolumeProfile.TryGet(out Tonemapping tonemapping)) - { - tonemapping.active = false; + if (cameraVolumeProfile.TryGet(out Tonemapping tonemapping)) + { + tonemapping.active = false; + } } } - _sunSource.shadows = LightShadows.Hard; + if (_sunSource) + { + _sunSource.shadows = LightShadows.Hard; + } } private void GraphicsHighQuality() @@ -207,32 +218,38 @@ private void GraphicsHighQuality() // update camera parameters foreach (var cam in _cameraObjectsList) { - cam.TryGetComponent(out var cameraData); - cam.TryGetComponent(out var cameraVolume); - var cameraVolumeProfile = cameraVolume.profile; + if (cam) + { + cam.TryGetComponent(out var cameraData); + cam.TryGetComponent(out var cameraVolume); + var cameraVolumeProfile = cameraVolume.profile; - cameraData.antialiasing = AntialiasingMode.SubpixelMorphologicalAntiAliasing; - cameraData.antialiasingQuality = AntialiasingQuality.High; - cameraData.renderPostProcessing = true; - cameraData.renderShadows = true; - cameraData.allowHDROutput = true; + cameraData.antialiasing = AntialiasingMode.SubpixelMorphologicalAntiAliasing; + cameraData.antialiasingQuality = AntialiasingQuality.High; + cameraData.renderPostProcessing = true; + cameraData.renderShadows = true; + cameraData.allowHDROutput = true; - if (cameraVolumeProfile.TryGet(out Bloom bloom)) - { - bloom.active = true; - bloom.intensity.value = 0.5f; - bloom.highQualityFiltering.overrideState = false; - bloom.highQualityFiltering.value = false; - } + if (cameraVolumeProfile.TryGet(out Bloom bloom)) + { + bloom.active = true; + bloom.intensity.value = 0.5f; + bloom.highQualityFiltering.overrideState = false; + bloom.highQualityFiltering.value = false; + } - if (cameraVolumeProfile.TryGet(out Tonemapping tonemapping)) - { - tonemapping.active = true; - tonemapping.mode.value = TonemappingMode.ACES; + if (cameraVolumeProfile.TryGet(out Tonemapping tonemapping)) + { + tonemapping.active = true; + tonemapping.mode.value = TonemappingMode.ACES; + } } } - _sunSource.shadows = LightShadows.Soft; + if (_sunSource) + { + _sunSource.shadows = LightShadows.Soft; + } } private void GraphicsUltraQuality()