Describe the bug
Opening the PointerProfile while there is no main camera in the currently opened scene, results in a NullReferenceException and the inspector failing to render the profile inspector.
To reproduce
Steps to reproduce the behavior:
- Open or create a scene in the Unity Editor without a main camera.
- Navigate to the custom or default profile (Can be any higher level profile, which also renders the
PointerProfile inspector)
- In the Input profile unfold the Pointer inspector.
- Observe the Inspector rendering collapsing and several
NullReferenceExpections being thrown in the console.
Expected behavior
PointerProfile is correctly rendered in the inspector.
Screenshots
Inspector:


Log after unfolding the PointerProfile
[10:31:23] No main camera found. Searching for cameras in the scene.
[10:31:23] The Mixed Reality Toolkit was unable to determine a main camera. Please tag the scene's primary camera as "MainCamera", in the hierarchy.
[10:31:23] NullReferenceException: Object reference not set to an instance of an object
StackTrace for the NullReferenceException:
NullReferenceException: Object reference not set to an instance of an object
Microsoft.MixedReality.Toolkit.Input.Editor.MixedRealityPointerProfileInspector.OnInspectorGUI () (at Assets/Plugins/MRTK/Core/Inspectors/Profiles/MixedRealityPointerProfileInspector.cs:113)
Microsoft.MixedReality.Toolkit.Utilities.Editor.MixedRealityInspectorUtility.DrawSubProfileEditor (UnityEngine.Object profileObject, System.Boolean renderProfileInBox) (at Assets/Plugins/MRTK/Core/Inspectors/Utilities/MixedRealityInspectorUtility.cs:540)
Microsoft.MixedReality.Toolkit.Editor.BaseMixedRealityProfileInspector.RenderProfileInternal (UnityEditor.SerializedProperty property, System.Type profileType, System.Boolean showCloneButton, System.Boolean renderProfileInBox, System.Type serviceType, System.Boolean profileRequiredOverride) (at Assets/Plugins/MRTK/Core/Inspectors/Profiles/BaseMixedRealityProfileInspector.cs:151)
Microsoft.MixedReality.Toolkit.Editor.BaseMixedRealityProfileInspector.RenderProfile (UnityEditor.SerializedProperty property, System.Type profileType, System.Boolean showCloneButton, System.Boolean renderProfileInBox, System.Type serviceType, System.Boolean profileRequiredOverride) (at Assets/Plugins/MRTK/Core/Inspectors/Profiles/BaseMixedRealityProfileInspector.cs:80)
Microsoft.MixedReality.Toolkit.Input.Editor.MixedRealityInputSystemProfileInspector+<>c__DisplayClass34_0.<OnInspectorGUI>b__2 () (at Assets/Plugins/MRTK/Core/Inspectors/Profiles/MixedRealityInputSystemProfileInspector.cs:121)
Microsoft.MixedReality.Toolkit.Editor.BaseMixedRealityProfileInspector.RenderFoldout (System.Boolean& currentState, System.String title, System.Action renderContent, System.String preferenceKey) (at Assets/Plugins/MRTK/Core/Inspectors/Profiles/BaseMixedRealityProfileInspector.cs:183)
Microsoft.MixedReality.Toolkit.Input.Editor.MixedRealityInputSystemProfileInspector.OnInspectorGUI () (at Assets/Plugins/MRTK/Core/Inspectors/Profiles/MixedRealityInputSystemProfileInspector.cs:117)
Microsoft.MixedReality.Toolkit.Utilities.Editor.MixedRealityInspectorUtility.DrawSubProfileEditor (UnityEngine.Object profileObject, System.Boolean renderProfileInBox) (at Assets/Plugins/MRT
Your setup
- Unity 2020.3.20f1
- MRTK 2.8.2
Target platform
Additional context
The throwing line is MixedRealityPointerProfileInspector.cs#L113, which makes the assumption that the Main Camera is always available.
Describe the bug
Opening the
PointerProfilewhile there is no main camera in the currently opened scene, results in aNullReferenceExceptionand the inspector failing to render the profile inspector.To reproduce
Steps to reproduce the behavior:
PointerProfileinspector)NullReferenceExpectionsbeing thrown in the console.Expected behavior
PointerProfileis correctly rendered in the inspector.Screenshots
Inspector:


Log after unfolding the PointerProfile
StackTrace for the
NullReferenceException:Your setup
Target platform
Additional context
The throwing line is MixedRealityPointerProfileInspector.cs#L113, which makes the assumption that the Main Camera is always available.