Skip to main content

ObjectHistory

A class in Root.Township, Alta.Populations.

Debug component that records an object's position and rotation every Update, FixedUpdate and LateUpdate into a ring buffer and draws them as gizmos.

Constructors​

MemberWhat it is
ObjectHistory()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

8 private and internal fields
MemberWhat it is
private int currentIndexNext slot to write in the ring buffer.
private ObjectHistory.SnapshotType gizmosToShowWhich snapshot kinds to draw.
private bool isClearingInspector Clear button. Nothing reads it in this build.
private NetworkRigidbody networkRigidbodyThe tracked object's NetworkRigidbody, if any.
private ObjectHistory.ObjectSnapshot[] objectHistoryThe ring buffer of snapshots.
private Transform objectToTrackThe transform being recorded.
private float positionGizmoSizeRadius of each snapshot sphere.
private ObjectHistory.ObjectTrackingSettings settingsWhich update loops to record in and the buffer size.

Methods​

MemberWhat it is
static ObjectHistory TrackObject(Transform target, ObjectHistory.ObjectTrackingSettings settings)Adds an ObjectHistory to the target and starts tracking it with the given settings.
8 private and internal methods
MemberWhat it is
private void AddObjectSnapshot(ObjectHistory.ObjectSnapshot snapshot)Writes a snapshot into the ring buffer, overwriting the oldest once full.
private void CaptureNetworkRigidbody()Records the tracked NetworkRigidbody's networked position and rotation.
private void FixedUpdate()Records a snapshot if fixed update tracking is on.
private void LateUpdate()Records a snapshot if late update tracking is on.
private void OnDrawGizmosSelected()Draws a sphere and forward ray for each snapshot of the chosen kinds. Probably throws until the buffer is full, since empty slots are null.
private void RecordObject(ObjectHistory.SnapshotType updateMethod)Records the tracked transform's current position and rotation.
private void Start()Allocates the buffer and finds the NetworkRigidbody if that tracking is on.
private void Update()Records a snapshot, and when network rigidbody tracking is on adds another Socket.EndOfReceival handler every frame (never removed).