Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Transformations] New Transformations system which replaces the old Solvers+Constraints system #11323

Closed
wants to merge 12 commits into from
Closed
4 changes: 2 additions & 2 deletions com.microsoft.mrtk.core/Editor/BaseInteractableEditor.cs
Expand Up @@ -80,6 +80,8 @@ protected override List<string> GetDerivedSerializedPropertyNames()

protected override void DrawProperties()
{
EditorGUILayout.PropertyField(disabledInteractorTypes);

xriBaseFoldout = EditorGUILayout.Foldout(xriBaseFoldout, EditorGUIUtility.TrTempContent("Base XRI Settings"), true, EditorStyles.foldoutHeader);
if (xriBaseFoldout)
{
Expand All @@ -92,8 +94,6 @@ protected override void DrawProperties()

protected override void DrawInteractableEvents()
{
EditorGUILayout.PropertyField(disabledInteractorTypes);

mrtkExpanded = EditorGUILayout.Foldout(mrtkExpanded, EditorGUIUtility.TrTempContent("MRTK Events"), true);

if (mrtkExpanded)
Expand Down
Expand Up @@ -21,7 +21,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
{
if (ShouldShow(property))
{
EditorGUI.PropertyField(position, property, label);
EditorGUI.PropertyField(position, property, label, true);
}
}

Expand All @@ -33,7 +33,7 @@ public override float GetPropertyHeight(SerializedProperty property, GUIContent
return 0f;
}

return base.GetPropertyHeight(property, label);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is not calling into the base implementation okay here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, base will only return the height of the property without accounting for the children (i.e, a single line + field for most assets), while using the static method provides options for also including the children.

return EditorGUI.GetPropertyHeight(property, true);
}

private bool ShouldShow(SerializedProperty property)
Expand Down
@@ -0,0 +1,137 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Microsoft.MixedReality.Toolkit.Editor;
using UnityEditor;
using UnityEngine;

namespace Microsoft.MixedReality.Toolkit.SpatialManipulation.Editor
{
/// <summary>
/// A custom inspector for ObjectManipulator used to separate
/// ObjectManipulator options into distinct foldout panels.
/// </summary>
[CustomEditor(typeof(NewObjectManipulator))]
[CanEditMultipleObjects]
public class NewObjectManipulatorInspector : StatefulInteractableInspector
{
private NewObjectManipulator instance;
private SerializedProperty allowedManipulations;
private SerializedProperty rotationAnchorNear;
private SerializedProperty rotationAnchorFar;
private SerializedProperty manipulationLogicTypes;
private SerializedProperty selectMode;

private SerializedProperty releaseBehavior;

private SerializedProperty smoothingFar;
private SerializedProperty smoothingNear;

// These alias to the XRI First/Last Select Entered/Exited events
private SerializedProperty manipulationStarted;
private SerializedProperty manipulationEnded;

protected override void OnEnable()
{
base.OnEnable();
instance = target as NewObjectManipulator;
allowedManipulations = SetUpProperty(nameof(allowedManipulations));

// Rotation anchor settings
rotationAnchorNear = SetUpProperty(nameof(rotationAnchorNear));
rotationAnchorFar = SetUpProperty(nameof(rotationAnchorFar));

// Manipulation logic
manipulationLogicTypes = SetUpProperty(nameof(manipulationLogicTypes));

// Physics
releaseBehavior = SetUpProperty(nameof(releaseBehavior));

//Smoothing
smoothingFar = SetUpProperty(nameof(smoothingFar));
smoothingNear = SetUpProperty(nameof(smoothingNear));

// Mirroring base XRI settings for easy access
selectMode = serializedObject.FindProperty("m_SelectMode");
manipulationStarted = serializedObject.FindProperty("m_FirstSelectEntered");
manipulationEnded = serializedObject.FindProperty("m_LastSelectExited");
}

static bool baseInteractableFoldout = false;
static bool advancedSettingFoldout = false;
static bool physicsFoldout = false;
static bool smoothingFoldout = false;
protected override void DrawProperties()
{
EditorGUILayout.Space();
EditorGUILayout.LabelField("Object Manipulator Settings", EditorStyles.boldLabel);
using (new EditorGUI.IndentLevelScope())
{
EditorGUILayout.PropertyField(allowedManipulations);

// This is just the XRI SelectMode property, but renamed/aliased to avoid confusion.
EditorGUILayout.PropertyField(selectMode, new GUIContent("Multiselect Mode", "Can the object can be grabbed by one interactor or multiple at a time?"));

if (advancedSettingFoldout = EditorGUILayout.Foldout(advancedSettingFoldout, "Advanced Object Manipulator Settings", true, EditorStyles.foldoutHeader))
{
using (new EditorGUI.IndentLevelScope())
{
EditorGUILayout.PropertyField(rotationAnchorNear);
EditorGUILayout.PropertyField(rotationAnchorFar);
EditorGUILayout.PropertyField(manipulationLogicTypes);

Rigidbody rb = instance.GetComponent<Rigidbody>();
if (physicsFoldout = EditorGUILayout.Foldout(physicsFoldout, "Physics", true))
{
using (new EditorGUI.IndentLevelScope())
{
if (rb != null && !rb.isKinematic)
{
EditorGUILayout.PropertyField(releaseBehavior);
}
else
{
EditorGUILayout.HelpBox("Physics options disabled. If you wish to enable physics options, add a Rigidbody component to this object.", MessageType.Info);
}
}
}

smoothingFoldout = EditorGUILayout.Foldout(smoothingFoldout, "Smoothing", true);
if (smoothingFoldout)
{
using (new EditorGUI.IndentLevelScope())
{
EditorGUILayout.PropertyField(smoothingFar);
EditorGUILayout.PropertyField(smoothingNear);
}
}
}
}
}

if (baseInteractableFoldout = EditorGUILayout.Foldout(baseInteractableFoldout, "Stateful Interactable Settings", true, EditorStyles.foldoutHeader))
{
using (new EditorGUI.IndentLevelScope())
{
base.DrawProperties();
}
}
serializedObject.ApplyModifiedProperties();
}

static bool manipulationEventsFoldout = false;
protected override void DrawInteractableEvents()
{
if (manipulationEventsFoldout = EditorGUILayout.Foldout(manipulationEventsFoldout, "Manipulation Events", true))
{
// These events just alias to the existing XRI FirstSelectEntered/LastSelectExited events,
// but are mirrored here for clarity + to be explicit that they can be used for manip start/end.
EditorGUILayout.PropertyField(manipulationStarted, new GUIContent("Manipulation Started [FirstSelectEntered]", "Fired when manipulation starts."));
EditorGUILayout.PropertyField(manipulationEnded, new GUIContent("Manipulation Ended [LastSelectExited]", "Fired when manipulation ends."));
}

base.DrawInteractableEvents();
serializedObject.ApplyModifiedProperties();
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.