Research a better way to get CursorModifier in Cursor.cs
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>());
}
}
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.
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:
- Removing the dead methods: GetModifiedPosition, GetModifiedRotation, GetModifiedScale
- 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 great suggestions. I'd say they warrant their own issue.
Fixed in vNEXT