MixedRealityToolkit-Unity icon indicating copy to clipboard operation
MixedRealityToolkit-Unity copied to clipboard

Research a better way to get CursorModifier in Cursor.cs

Open StephenHodgson opened this issue 10 years ago • 4 comments

I love the new input module, but there's gotta be a better way we can get the cursor modifier than GetComponent whenever we get a new focused object.

Probably not an easy way to around this, but it would be nice.

Cursor.cs line 253:

protected virtual void OnFocusedObjectChanged(GameObject previousObject, GameObject newObject)
{
    TargetedObject = newObject;
    if (newObject != null)
    {
        OnActiveModifier(newObject.GetComponent<CursorModifier>());
    }
}

StephenHodgson avatar Nov 18 '16 13:11 StephenHodgson

The only thing here is that OnActiveModifier is also for setting the modifier to null. So as-is it's not ideal but still handles the base side of having OnActiveModifier handle both new modifier or no modifier. Ideally I think we would want the modifier to self-register on focus and the ability to override. Supporting the ability to have a modifier that does not require focus but is enabled through other mechanisms.

paseb avatar Nov 19 '16 00:11 paseb

I do not really see a way around this without sacrificing the flexibility provided.

While the GetComponent is sort of slow, it should not really be a problem unless you are performing hundreds or thousands during the same update cycle.

I would much rather we focused on cleaning the interface by either:

  1. Removing the dead methods: GetModifiedPosition, GetModifiedRotation, GetModifiedScale
  2. or, Removing the all-in-on method: GetModifiedTransform where I would prefer the individuality of split methods. That is go with option 2, and refactor accordingly.

Danta1st avatar Jun 01 '17 13:06 Danta1st

@Danta1st great suggestions. I'd say they warrant their own issue.

StephenHodgson avatar Jun 01 '17 15:06 StephenHodgson

Fixed in vNEXT

StephenHodgson avatar May 17 '18 16:05 StephenHodgson