Class ChainTargetSelector
Selects a chain of UnityEngine.GameObjects starting from the context object, such as for chain lightning or similar effects. Each link in the chain is the closest unselected UnityEngine.GameObject within ChainRadius of the previous target.
[Serializable]
public class ChainTargetSelector : TargetSelector
- Inheritance
-
ChainTargetSelector
- Inherited Members
Fields
ChainLength
The maximum number of targets to select in the chain (including the initial context).
[Tooltip("The maximum number of targets to select in the chain (including the initial context).")]
[Min(1)]
public int ChainLength
Field Value
ChainRadius
The radius to search for the next target in the chain, in Unity units.
[Tooltip("The radius to search for the next target in the chain, in Unity units.")]
[Min(0)]
public float ChainRadius
Field Value
MaxHits
Sizing hint for the per-jump overlap buffer. Not a cap on the chain.
[Tooltip("Starting size of the per-jump overlap buffer. The chain limit is ChainLength; this only affects allocation.")]
[Min(1)]
public int MaxHits
Field Value
Remarks
The chain's actual limit is ChainLength, which bounds the walk directly; each jump keeps exactly one link (the nearest unvisited candidate) however many candidates the query returned. This value only chooses the buffer's STARTING size through QueryBufferSize(int), and TryGrowQueryBuffer<T>(ref T[], int) grows past it whenever a query comes back full — so setting it low costs a reallocation in a crowd, never a lost candidate.
TargetLayer
The layer mask used to filter which UnityEngine.GameObjects can be selected as chain targets.
[Tooltip("The layer mask used to filter which GameObjects can be selected as chain targets.")]
public LayerMask TargetLayer
Field Value
- LayerMask
Methods
SelectTargets(EventData)
Selects a chain of UnityEngine.GameObjects starting from the given context object. Each subsequent target is the closest unselected UnityEngine.GameObject within ChainRadius of the previous one. The chain will contain at most ChainLength targets.
public override IEnumerable<GameObject> SelectTargets(EventData eventData)
Parameters
eventDataEventDataThe event driving the selection; its context object starts the chain.
Returns
- IEnumerable<GameObject>
An enumerable of UnityEngine.GameObjects representing the chain of selected targets, starting with the context object.