MixedRealityToolkit / MixedRealityToolkit-Unity

This repository holds the third generation of the Mixed Reality Toolkit for Unity. The latest version of the MRTK can be found here.
BSD 3-Clause "New" or "Revised" License
411 stars 111 forks source link

[BUG] [EDITOR] `Constraint Manager`'s button "Go to component" doesn't work for custom TransformConstraint #838

Open anonymous2585 opened 4 months ago

anonymous2585 commented 4 months ago

Describe the bug

When using a custom script that extends TransformConstraint, the "Go to component" button in the Constraint Manager doesn't work when clicked.

To reproduce

Steps to reproduce the behavior:

  1. Import this script
    
    using MixedReality.Toolkit;
    using MixedReality.Toolkit.SpatialManipulation;

public class CustomConstraint : TransformConstraint { public override TransformFlags ConstraintType => TransformFlags.Rotate;

public override void ApplyConstraint(ref MixedRealityTransform transform)
{
    // not necessary for this issue
}

}


2. Open scene `HandInteractionExample`
3. Add this constraint on one of the ObjectManipulator
4. On the `Constraint Manager`, click on 'Go to component' for the custom constraint
5. See warning `Item Custom Constraint not found in window Inspector.`

## Expected behavior

The component is highlighted just as the built-in components.

## Your setup (please complete the following information)

- Unity Version 2021.3.21f1
- MRTK Version or Commit [main@d818d18](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/commit/d818d1807a2a662d60db9bb9306d2a928a54c084)

## Additional context

- When changing `$"{ObjectNames.NicifyVariableName(constraintName)}"` to `$"{ObjectNames.NicifyVariableName(constraintName)} (Script)"` in [ConstraintManagerEditor.cs](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/blob/d818d1807a2a662d60db9bb9306d2a928a54c084/org.mixedrealitytoolkit.spatialmanipulation/Editor/Constraints/ConstraintManagerEditor.cs#L113), the custom component is highlighted but break for MRTK's constraints.
- User work-around is to add `[AddComponentMenu("MRTK/Spatial Manipulation/CustomConstraint")]` attribute on the class. It changes the displayed name in inspector and removes the " (Script)" part. But it's better if this feature works out of the box for all scripts.
shaynie commented 4 months ago

@AMollis thinks this may be a dupe. Investigating.

AMollis commented 4 months ago

I was thinking of this issue

The #313 issue is slightly different than this new issue.