// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using Microsoft.MixedReality.Toolkit.Utilities; using UnityEngine; namespace Microsoft.MixedReality.Toolkit.CameraSystem { public abstract class BaseCameraSettingsProvider : BaseDataProvider, IMixedRealityCameraSettingsProvider { /// /// Constructor. /// /// The instance of the camera system which is managing this provider. /// Friendly name of the provider. /// Provider priority. Used to determine order of instantiation. /// The provider's configuration profile. protected BaseCameraSettingsProvider( IMixedRealityCameraSystem cameraSystem, string name = null, uint priority = DefaultPriority, BaseCameraSettingsProfile profile = null) : base(cameraSystem, name, priority, profile) { } /// public virtual bool IsOpaque { get; } = false; /// public virtual void ApplyConfiguration() { // It is the responsibility of the camera settings provider to set the display settings (this allows overriding the // default values with per-camera provider values). MixedRealityCameraProfile cameraProfile = Service?.CameraProfile; if (cameraProfile == null) { return; } if (IsOpaque) { CameraCache.Main.clearFlags = cameraProfile.CameraClearFlagsOpaqueDisplay; CameraCache.Main.nearClipPlane = cameraProfile.NearClipPlaneOpaqueDisplay; CameraCache.Main.farClipPlane = cameraProfile.FarClipPlaneOpaqueDisplay; CameraCache.Main.backgroundColor = cameraProfile.BackgroundColorOpaqueDisplay; QualitySettings.SetQualityLevel(cameraProfile.OpaqueQualityLevel, false); } else { CameraCache.Main.clearFlags = cameraProfile.CameraClearFlagsTransparentDisplay; CameraCache.Main.backgroundColor = cameraProfile.BackgroundColorTransparentDisplay; CameraCache.Main.nearClipPlane = cameraProfile.NearClipPlaneTransparentDisplay; CameraCache.Main.farClipPlane = cameraProfile.FarClipPlaneTransparentDisplay; QualitySettings.SetQualityLevel(cameraProfile.TransparentQualityLevel, false); } } } }