Class ActorIdentifier
Assigns a runtime GUID to an actor and decorates it with designer-assigned ScriptableTags so that analysis scripts can correlate log entries across multiple data sinks and filter by role.
[DisallowMultipleComponent]
public class ActorIdentifier : MonoBehaviour, IDataLoggable, IUniqueIdentifier, IScriptableTagged, IHandle<ActorTagsRequest>
Inheritance
Implements
Examples
Subscribe to ActorTagsRequest via the event aggregator to retrieve the player actor's tags without a direct scene reference, then use ScriptableTag[]) to filter by role — for example, to show vehicle-specific UI only for the driver pawn:
[SerializeField] private ScriptableTag[] _vehicleTags; // assign in Inspector
private void OnEnable()
{
if (UnityServiceLocator.Current.TryGet(out var aggregator))
{
// ActorIdentifier on the player GameObject handles this request and
// invokes the callback with its ScriptableTag array.
aggregator.Publish(new ActorTagsRequest(tags => UpdateVisuals(tags)));
}
}
private void UpdateVisuals(ScriptableTag[] tags)
{
// Show driver UI only when the active pawn carries at least one vehicle tag.
bool isDriver = tags != null &&
GetComponent().MatchAnyTags(_vehicleTags);
driverHUD.SetActive(isDriver);
}
Remarks
The GUID is generated fresh each play-session rather than authored in the scene because actors are instantiated programmatically in some scenarios; a stable GUID is not needed — only uniqueness within a single study run.
Responding to ActorTagsRequest via the event aggregator (only for player actors) lets collision, assessment, and data-logging components discover the player's role without holding a hard reference to the player GameObject.
Properties
GUID
Gets the globally unique identifier for this actor instance.
public Guid GUID { get; }
Property Value
Tags
Gets the list of ScriptableTag?text=scriptable+tags assigned to this actor.
public ScriptableTag[] Tags { get; }
Property Value
Methods
Handle(ActorTagsRequest)
Handles an ActorTagsRequest by responding with this actor's tags.
public void Handle(ActorTagsRequest request)
Parameters
| Name | Type | Description |
|---|---|---|
request | ActorTagsRequest | The request containing a callback for tag data. |
MatchAllTags(ScriptableTag[])
Determines whether the actor has all tags present in the provided list.
public bool MatchAllTags(ScriptableTag[] tags)
Parameters
| Name | Type | Description |
|---|---|---|
tags | ScriptableTag[] | The tags to compare with. |
Returns
bool — true if all provided tags are present; otherwise, false.
MatchAnyTags(ScriptableTag[])
Determines whether the actor has at least one tag that matches the provided list.
public bool MatchAnyTags(ScriptableTag[] tags)
Parameters
| Name | Type | Description |
|---|---|---|
tags | ScriptableTag[] | The tags to compare with. |
Returns
bool — true if any tag matches; otherwise, false.