Class NamedSceneObjectTargetSelector
Resolves a scene UnityEngine.GameObject by name at runtime. Designed for asset-based Triggers that need to point at a specific scene object — selectors serialized on ScriptableObject assets cannot hold direct scene references, but they can hold a name string and look the object up when the trigger fires.
The lookup is scoped to the context's scene (whatever scene the event's Target or Initiator lives in). If no scene context is available, the active scene is used. Names are compared exactly (case sensitive). For non-unique names, use TaggedSceneObjectTargetSelector instead, or compose this selector with per-target conditions to disambiguate.
Performance: the lookup walks the scene's root objects and their descendants on every fire. For frequent triggers, cache the resolved GameObject in your scene wiring rather than depending on a name lookup.
[Serializable]
public class NamedSceneObjectTargetSelector : TargetSelector
- Inheritance
-
NamedSceneObjectTargetSelector
- Inherited Members
Fields
IncludeInactive
When true, also searches inactive GameObjects in the scene hierarchy.
[Tooltip("Include inactive GameObjects in the scene scan.")]
public bool IncludeInactive
Field Value
ObjectName
The name of the GameObject to find in the scene. Compared exactly.
[Tooltip("Name of the GameObject to find in the current scene.")]
public string ObjectName
Field Value
Methods
SelectTargets(EventData)
Selects targets based on the supplied event context.
public override IEnumerable<GameObject> SelectTargets(EventData eventData)
Parameters
eventDataEventDataThe event data driving the selection. Target (when set) or Initiator typically serves as the spatial origin.
Returns
- IEnumerable<GameObject>
The selected GameObjects.