Class DataCollector
Aggregates per-frame data snapshots from IDataLoggable components in its own scene subtree and delivers them to the central analysis system as a single MasterDatalog entry.
[DisallowMultipleComponent]
public class DataCollector : MonoBehaviour
Inheritance
Remarks
Each actor in the scene (vehicle, pedestrian, drone, …) owns one DataCollector at the
root of its hierarchy. This gives the analysis system a clean ownership boundary: when
Collect is called, the collector gathers readings from every
IDataLoggable on that actor and nothing else. Without this scoping, a single
collector placed at the scene root would need to know how to partition data by actor, or every
component would need to self-register with the analysis system individually.
Nested DataCollectors are handled by ownership: PopulateDataLoggables only
claims an IDataLoggable if this collector is the nearest ancestor collector in the
hierarchy. If a child game object has its own collector, that child's loggables belong to the
child collector. This mirrors the scene hierarchy's ownership semantics and prevents duplicate
data entries.
Methods
Collect()
Polls every owned IDataLoggable, bundles the results into a
MasterDatalog, and returns it — or null if this collector is disabled
or no loggables produced data.
public DataLog Collect()
Returns
DataLog — A MasterDatalog containing the collected readings, cast to
DataLog, or null if no data was produced.
Remarks
The return type is declared as DataLog (the polymorphic base)
rather than MasterDatalog so that the analysis service can store heterogeneous
log entries in a single list without knowing each concrete type. Callers that need to inspect
the structure should downcast to MasterDatalog.
Returning null when the result is empty avoids allocating placeholder entries in the
analysis output for actors that produced no meaningful data in a given frame (e.g., actors
that are inactive or out of range of the logging trigger).