Search Unity

Feature Request Extending the TrackedPoseDriver (with Editor)

Discussion in 'XR Interaction Toolkit and Input' started by Murrrly, Dec 14, 2020.

  1. Murrrly

    Murrrly

    Joined:
    Apr 25, 2013
    Posts:
    16
    Hi, I'm working on a tool that's designed to be used in VR and I found the need to extend the TrackedPoseDriver class, but have run into one issue that I've experience before with other components. When I extend the class, I lose its CustomEditor which has some helpful functionality as well as the familiarity to the user.

    Since I want to distribute this tool to other Unity users, I want to keep my changes as minimal as possible. So the ideal for me would be that the Editor class for the TrackedPoseDriver would have the `editorForChildClasses` parameter set in the CustomEditor attribute and append any additional fields in the inheriting class to the inspector.

    Otherwise I'm really happy about how easy it is to extend the class to do what I want!
    Thanks ~

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.SpatialTracking;
    3.  
    4. public class TrackedPoseDriverWithOffset : TrackedPoseDriver
    5. {
    6.     [Header("Offset")]
    7.     [SerializeField] private Vector3 _position;
    8.     [SerializeField] private Quaternion _rotation;
    9.    
    10.     protected override void SetLocalTransform(Vector3 newPosition, Quaternion newRotation, PoseDataFlags poseFlags)
    11.     {
    12.         newRotation *= _rotation;
    13.         newPosition += newRotation * _position;
    14.        
    15.         base.SetLocalTransform(newPosition, newRotation, poseFlags);
    16.     }
    17. }
     
  2. mfuad

    mfuad

    Unity Technologies

    Joined:
    Jun 12, 2018
    Posts:
    335
    Thanks for the feedback! We'll put this in our backlog of to-do's.