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 ~
using UnityEngine;
using UnityEngine.SpatialTracking;
public class TrackedPoseDriverWithOffset : TrackedPoseDriver
{
[Header("Offset")]
[SerializeField] private Vector3 _position;
[SerializeField] private Quaternion _rotation;
protected override void SetLocalTransform(Vector3 newPosition, Quaternion newRotation, PoseDataFlags poseFlags)
{
newRotation *= _rotation;
newPosition += newRotation * _position;
base.SetLocalTransform(newPosition, newRotation, poseFlags);
}
}