diff --git a/Runtime/HumanoidControl/Scripts/Extensions/Sensor.cs b/Runtime/HumanoidControl/Scripts/Extensions/Sensor.cs index 042d0b5..ee127a6 100644 --- a/Runtime/HumanoidControl/Scripts/Extensions/Sensor.cs +++ b/Runtime/HumanoidControl/Scripts/Extensions/Sensor.cs @@ -13,8 +13,9 @@ namespace Passer { public virtual string name { get { return ""; } } - //public Transform sensorTransform; - + /// + /// The sensor used for tracking + /// public SensorComponent sensorComponent; public virtual void Start(Transform targetTransform) { @@ -30,9 +31,6 @@ namespace Passer { if (sensorComponent == null) return; - //if (sensorTransform == null) - // return; - if (!Application.isPlaying) sensorComponent.gameObject.SetActive(shown); diff --git a/Runtime/HumanoidControl/Scripts/Extensions/SensorComponent.cs b/Runtime/HumanoidControl/Scripts/Extensions/SensorComponent.cs index f344e68..a1ace42 100644 --- a/Runtime/HumanoidControl/Scripts/Extensions/SensorComponent.cs +++ b/Runtime/HumanoidControl/Scripts/Extensions/SensorComponent.cs @@ -2,17 +2,43 @@ namespace Passer.Tracking { - public class SensorComponent : MonoBehaviour { + /// + /// A sensor component is used to add tracking to a transform + /// + /// Custom sensor implementation can be made by deriving from this class. + public abstract class SensorComponent : MonoBehaviour { + /// + /// The transform which is used as the root of the tracking space + /// protected Transform trackerTransform; + /// + /// The tracking status of the sensor + /// public Tracker.Status status; + /// + /// The confidence (0..1) of the tracked rotation + /// public float rotationConfidence; + /// + /// The confidence (0..1) of the tracked position + /// public float positionConfidence; + /// + /// Is used to set whether the sensor updates itself + /// + /// When enabled, the sensor will update itself. + /// When disabled, StartComponent and UpdateComponent need to be called to update the tracking status. public bool autoUpdate = true; protected bool _show; + /// + /// The render status of the sensor + /// + /// When enabled, sensors with renderers attached will be rendered. + /// When disabled, sensors will not be rendered. public virtual bool show { set { if (value == true && !_show) { @@ -31,6 +57,9 @@ namespace Passer.Tracking { } } + /// + /// Enable or disable the renderers for this sensor. + /// protected bool renderController { set { Renderer[] renderers = this.GetComponentsInChildren(); @@ -39,33 +68,50 @@ namespace Passer.Tracking { } } + /// + /// Initializes the sensor. + /// + /// When trackerTransform is null, it will be set automatically to the parent of this transform. virtual protected void Awake() { if (trackerTransform == null) trackerTransform = transform.parent; } + /// + /// Starts the sensor + /// + /// Does nothing at this moment. virtual protected void Start() { - //if (autoUpdate) - // StartComponent(trackerTransform); } + /// + /// Start the manual updating of the sensor. + /// + /// + /// When this function has been called, autoUpdate will be disabled and the sensor will no longer update from Unity Updates. + /// Instead, UpdateComponent needs to be called to update the sensor data public virtual void StartComponent(Transform trackerTransform) { - // When this function has been called, the sensor will no longer update from Unity Updates. - // Instead, UpdateComponent needs to be called to update the sensor data autoUpdate = false; this.trackerTransform = trackerTransform; } + /// + /// Updates the sensor + /// + /// When autoUpdate is enabled, this will call UpdateComponent. private void Update() { if (autoUpdate) UpdateComponent(); } + /// + /// Update the component manually + /// + /// This function is meant to be overridden public virtual void UpdateComponent() { status = Tracker.Status.Unavailable; positionConfidence = 0; rotationConfidence = 0; - //gameObject.SetActive(showRealObjects); } }