diff --git a/Inspectors/Profiles/BaseMixedRealityProfileInspector.cs b/Inspectors/Profiles/BaseMixedRealityProfileInspector.cs
index 99c539f82..43194dc55 100644
--- a/Inspectors/Profiles/BaseMixedRealityProfileInspector.cs
+++ b/Inspectors/Profiles/BaseMixedRealityProfileInspector.cs
@@ -6,6 +6,7 @@
using UnityEngine;
using XRTK.Definitions;
using XRTK.Inspectors.Extensions;
+using XRTK.Inspectors.Utilities;
using XRTK.Services;
using XRTK.Utilities.Async;
@@ -35,6 +36,17 @@ protected virtual void OnEnable()
ThisProfile = profile;
}
+ protected void RenderHeader()
+ {
+ MixedRealityInspectorUtility.RenderMixedRealityToolkitLogo();
+
+ if (ThisProfile.ParentProfile != null &&
+ GUILayout.Button("Back to parent profile"))
+ {
+ Selection.activeObject = ThisProfile.ParentProfile;
+ }
+ }
+
///
/// Renders a .
///
diff --git a/Inspectors/Profiles/MixedRealityServiceProviderProfileInspector.cs b/Inspectors/Profiles/MixedRealityServiceProviderProfileInspector.cs
index 058a3e471..08ddb463c 100644
--- a/Inspectors/Profiles/MixedRealityServiceProviderProfileInspector.cs
+++ b/Inspectors/Profiles/MixedRealityServiceProviderProfileInspector.cs
@@ -17,6 +17,7 @@ namespace XRTK.Inspectors.Profiles
[CustomEditor(typeof(BaseMixedRealityServiceProfile<>))]
public class MixedRealityServiceProfileInspector : BaseMixedRealityProfileInspector
{
+ private readonly GUIContent ProfileContent = new GUIContent("Profile", "The configuration profile for this service.");
private ReorderableList configurationList;
private int currentlySelectedConfigurationOption;
@@ -120,6 +121,8 @@ private void DrawConfigurationOptionElement(Rect rect, int index, bool isActive,
foreach (var parameterInfo in parameters)
{
+ if (parameterInfo.ParameterType.IsAbstract) { continue; }
+
if (parameterInfo.ParameterType.IsSubclassOf(typeof(BaseMixedRealityProfile)))
{
profileType = parameterInfo.ParameterType;
@@ -141,7 +144,7 @@ private void DrawConfigurationOptionElement(Rect rect, int index, bool isActive,
if (profileType != null)
{
- EditorGUI.LabelField(profileLabelRect, "Profile");
+ EditorGUI.LabelField(profileLabelRect, ProfileContent);
var isNullProfile = configurationProfileProperty.objectReferenceValue == null;
var buttonWidth = isNullProfile ? 20f : 42f;
@@ -150,7 +153,26 @@ private void DrawConfigurationOptionElement(Rect rect, int index, bool isActive,
var profileObjectRect = new Rect(profilePosition, profileHeight, profileObjectWidth - scrollOffset, EditorGUIUtility.singleLineHeight);
var buttonRect = new Rect(profilePosition + profileObjectWidth - scrollOffset, profileHeight, buttonWidth, EditorGUIUtility.singleLineHeight);
- configurationProfileProperty.objectReferenceValue = EditorGUI.ObjectField(profileObjectRect, configurationProfileProperty.objectReferenceValue, profileType, false);
+ var newProfileObjectReference = EditorGUI.ObjectField(profileObjectRect, configurationProfileProperty.objectReferenceValue, profileType, false);
+
+ if (newProfileObjectReference is BaseMixedRealityProfile newProfile)
+ {
+ var newProfileType = newProfile.GetType();
+ if (newProfileType == profileType ||
+ newProfileType.IsSubclassOf(profileType))
+ {
+ configurationProfileProperty.objectReferenceValue = newProfileObjectReference;
+ }
+ else
+ {
+ Debug.LogError($"{newProfileObjectReference.name} does not derive from {profileType.Name}!");
+ }
+ }
+ else if (newProfileObjectReference is null)
+ {
+ configurationProfileProperty.objectReferenceValue = null;
+ }
+
update = GUI.Button(buttonRect, isNullProfile ? NewProfileContent : CloneProfileContent);
if (update)
@@ -167,7 +189,19 @@ private void DrawConfigurationOptionElement(Rect rect, int index, bool isActive,
}
else
{
- EditorGUI.PropertyField(profileRect, configurationProfileProperty);
+ EditorGUI.LabelField(profileRect, "No Configuration Profile needed");
+ }
+
+ if (configurationProfileProperty.objectReferenceValue != null)
+ {
+ var renderedProfile = configurationProfileProperty.objectReferenceValue as BaseMixedRealityProfile;
+ Debug.Assert(renderedProfile != null);
+
+ if (renderedProfile.ParentProfile == null ||
+ renderedProfile.ParentProfile != ThisProfile)
+ {
+ renderedProfile.ParentProfile = ThisProfile;
+ }
}
if (update ||
diff --git a/Inspectors/PropertyDrawers/TypeReferencePropertyDrawer.cs b/Inspectors/PropertyDrawers/TypeReferencePropertyDrawer.cs
index 5bee8c16b..9d54cbcbd 100644
--- a/Inspectors/PropertyDrawers/TypeReferencePropertyDrawer.cs
+++ b/Inspectors/PropertyDrawers/TypeReferencePropertyDrawer.cs
@@ -29,6 +29,7 @@ public class TypeReferencePropertyDrawer : PropertyDrawer
private static readonly Dictionary TypeMap = new Dictionary();
private static readonly int ControlHint = typeof(TypeReferencePropertyDrawer).GetHashCode();
private static readonly GUIContent TempContent = new GUIContent();
+ private static readonly GUIContent RepairContent = new GUIContent("Repair", "Try to repair the reference");
private static readonly Color EnabledColor = Color.white;
private static readonly Color DisabledColor = Color.Lerp(Color.white, Color.clear, 0.5f);
@@ -287,15 +288,18 @@ private static void DrawTypeSelectionControl(Rect position, SerializedProperty s
}
else
{
+ const float leftPadding = 8f;
+ const float iconSize = 24f;
+ const float buttonWidth = 40f;
var errorContent = EditorGUIUtility.IconContent("d_console.erroricon.sml");
- GUI.Label(new Rect(position.width, position.y, position.width, position.height), errorContent);
+ GUI.Label(new Rect(EditorGUIUtility.currentViewWidth - iconSize - leftPadding, position.y, iconSize, iconSize), errorContent);
- var dropdownPosition = new Rect(position.x, position.y, position.width - 90, position.height);
- var buttonPosition = new Rect(position.width - 75, position.y, 75, position.height);
+ var dropdownPosition = new Rect(position.x, position.y, position.width - buttonWidth - 28f, position.height);
+ var buttonPosition = new Rect(EditorGUIUtility.currentViewWidth - buttonWidth - leftPadding - iconSize, position.y, buttonWidth, position.height);
DrawTypeSelectionControl(dropdownPosition, label, ref reference, filter);
- if (GUI.Button(buttonPosition, "Try Repair", EditorStyles.miniButton))
+ if (GUI.Button(buttonPosition, RepairContent, EditorStyles.miniButton))
{
TypeSearch(referenceProperty, ref reference, filter, true);
}