Skip to content

Commit

Permalink
Add support for editTimeDisplayType
Browse files Browse the repository at this point in the history
  • Loading branch information
keveleigh committed Jul 7, 2022
1 parent 3591e19 commit 1993156
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ namespace Microsoft.MixedReality.Toolkit
[HelpURL("https://docs.microsoft.com/windows/mixed-reality/mrtk-unity/configuration/mixed-reality-configuration-guide#camera")]
public class MixedRealityCameraProfile : BaseMixedRealityProfile
{
[SerializeField]
[Tooltip("The camera settings to apply at edit time, for ease of building a specific type of experience.")]
private DisplayType editTimeDisplayType = DisplayType.Transparent;

internal DisplayType EditTimeDisplayType => editTimeDisplayType;

[SerializeField]
[Tooltip("Configuration objects describing the registered settings providers.")]
private MixedRealityCameraSettingsConfiguration[] settingsConfigurations = new MixedRealityCameraSettingsConfiguration[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class MixedRealityCameraProfileInspector : BaseDataProviderServiceInspect
private bool showDisplaySettings = false;
private const string showDisplaySettingsPreferenceKey = "ShowCameraSystem_DisplaySettings_PreferenceKey";

private SerializedProperty editTimeDisplayType;

private SerializedProperty opaqueNearClip;
private SerializedProperty opaqueFarClip;
private SerializedProperty opaqueClearFlags;
Expand Down Expand Up @@ -48,6 +50,8 @@ protected override void OnEnable()
{
base.OnEnable();

editTimeDisplayType = serializedObject.FindProperty("editTimeDisplayType");

opaqueNearClip = serializedObject.FindProperty("nearClipPlaneOpaqueDisplay");
opaqueFarClip = serializedObject.FindProperty("farClipPlaneOpaqueDisplay");
opaqueClearFlags = serializedObject.FindProperty("cameraClearFlagsOpaqueDisplay");
Expand All @@ -73,6 +77,8 @@ public override void OnInspectorGUI()
{
serializedObject.Update();

EditorGUILayout.PropertyField(editTimeDisplayType);

RenderFoldout(ref showProviders, "Camera Settings Providers", () =>
{
using (new EditorGUI.IndentLevelScope())
Expand Down
35 changes: 21 additions & 14 deletions Assets/MRTK/Core/Providers/BaseCameraSettingsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,41 @@ protected BaseCameraSettingsProvider(
string name = null,
uint priority = DefaultPriority,
BaseCameraSettingsProfile profile = null) : base(cameraSystem, name, priority, profile)
{ }
{
CameraProfile = cameraSystem?.CameraProfile;
}

protected MixedRealityCameraProfile CameraProfile { get; }

/// <inheritdoc/>
public virtual bool IsOpaque { get; } = false;
public virtual bool IsOpaque =>
Application.isEditor
&& !Application.isPlaying
&& CameraProfile != null
&& CameraProfile.EditTimeDisplayType == DisplayType.Opaque;

/// <inheritdoc/>
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 (CameraProfile == null || CameraCache.Main == 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);
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);
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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RenderSettings:
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 0}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
Expand Down
2 changes: 2 additions & 0 deletions Assets/MRTK/Providers/OpenXR/Scripts/OpenXRCameraSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public override void Disable()

/// <inheritdoc/>
public override bool IsOpaque =>
(Application.isEditor && !Application.isPlaying) ?
base.IsOpaque :
XRSubsystemHelpers.DisplaySubsystem == null
|| !XRSubsystemHelpers.DisplaySubsystem.running
|| XRSubsystemHelpers.DisplaySubsystem.displayOpaque;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using Microsoft.MixedReality.Toolkit.CameraSystem;
using Microsoft.MixedReality.Toolkit.Utilities;
using UnityEngine;

#if UNITY_WSA
using UnityEngine.XR.WSA;
Expand Down Expand Up @@ -40,6 +41,8 @@ public WindowsMixedRealityCameraSettings(

/// <inheritdoc/>
public override bool IsOpaque =>
(Application.isEditor && !Application.isPlaying) ?
base.IsOpaque :
#if UNITY_WSA
HolographicSettings.IsDisplayOpaque;
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ private async void EnableIfLoaderBecomesActive()

/// <inheritdoc/>
public override bool IsOpaque =>
(Application.isEditor && !Application.isPlaying) ?
base.IsOpaque :
XRSubsystemHelpers.DisplaySubsystem == null
|| !XRSubsystemHelpers.DisplaySubsystem.running
|| XRSubsystemHelpers.DisplaySubsystem.displayOpaque;
Expand Down
3 changes: 3 additions & 0 deletions Assets/MRTK/Providers/XRSDK/GenericXRSDKCameraSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using Microsoft.MixedReality.Toolkit.CameraSystem;
using Microsoft.MixedReality.Toolkit.Utilities;
using UnityEngine;

#if SPATIALTRACKING_ENABLED
using UnityEngine.SpatialTracking;
Expand Down Expand Up @@ -42,6 +43,8 @@ public GenericXRSDKCameraSettings(

/// <inheritdoc/>
public override bool IsOpaque =>
(Application.isEditor && !Application.isPlaying) ?
base.IsOpaque :
XRSubsystemHelpers.DisplaySubsystem == null
|| !XRSubsystemHelpers.DisplaySubsystem.running
|| XRSubsystemHelpers.DisplaySubsystem.displayOpaque;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ MonoBehaviour:
m_Name: DefaultMixedRealityCameraProfile
m_EditorClassIdentifier:
isCustomProfile: 0
editTimeDisplayType: 1
settingsConfigurations:
- componentType:
reference: Microsoft.MixedReality.Toolkit.WindowsMixedReality.WindowsMixedRealityCameraSettings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ MonoBehaviour:
m_Name: DefaultHoloLens1CameraProfile
m_EditorClassIdentifier:
isCustomProfile: 0
editTimeDisplayType: 1
settingsConfigurations:
- componentType:
reference: Microsoft.MixedReality.Toolkit.WindowsMixedReality.WindowsMixedRealityCameraSettings,
Expand Down Expand Up @@ -44,9 +45,9 @@ MonoBehaviour:
settingsProfile: {fileID: 11400000, guid: 32349edfa9bacb94a9fe58923e9a2400, type: 2}
nearClipPlaneOpaqueDisplay: 0.3
farClipPlaneOpaqueDisplay: 1000
cameraClearFlagsOpaqueDisplay: 2
cameraClearFlagsOpaqueDisplay: 1
backgroundColorOpaqueDisplay: {r: 0, g: 0, b: 0, a: 1}
opaqueQualityLevel: 0
opaqueQualityLevel: 5
nearClipPlaneTransparentDisplay: 0.3
farClipPlaneTransparentDisplay: 50
cameraClearFlagsTransparentDisplay: 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ MonoBehaviour:
m_Name: DefaultHoloLens2CameraProfile
m_EditorClassIdentifier:
isCustomProfile: 0
editTimeDisplayType: 1
settingsConfigurations:
- componentType:
reference: Microsoft.MixedReality.Toolkit.WindowsMixedReality.WindowsMixedRealityCameraSettings,
Expand Down Expand Up @@ -44,9 +45,9 @@ MonoBehaviour:
settingsProfile: {fileID: 11400000, guid: 32349edfa9bacb94a9fe58923e9a2400, type: 2}
nearClipPlaneOpaqueDisplay: 0.1
farClipPlaneOpaqueDisplay: 1000
cameraClearFlagsOpaqueDisplay: 2
cameraClearFlagsOpaqueDisplay: 1
backgroundColorOpaqueDisplay: {r: 0, g: 0, b: 0, a: 1}
opaqueQualityLevel: 0
opaqueQualityLevel: 5
nearClipPlaneTransparentDisplay: 0.1
farClipPlaneTransparentDisplay: 50
cameraClearFlagsTransparentDisplay: 2
Expand Down

0 comments on commit 1993156

Please sign in to comment.