Class LineTargetSelector
Selects all UnityEngine.GameObjects along a line (ray) from the context in a given direction and distance. Useful for beam, projectile, or piercing effects.
[Serializable]
public class LineTargetSelector : TargetSelector
- Inheritance
-
LineTargetSelector
- Inherited Members
Fields
Length
Length of the line.
[Tooltip("Length of the line.")]
[Min(0)]
public float Length
Field Value
MaxHits
How many distinct bodies the line may hit. Zero or less pierces everything on it.
[Tooltip("How many distinct bodies the line may hit. 1 stops at the first; 0 pierces everything on the line.")]
[Min(0)]
public int MaxHits
Field Value
Remarks
[Min(0)], not [Min(1)]. The gather below treats a non-positive cap as
uncapped — matching CappedCount(int, int) and every other selector —
and that was introduced precisely so a beam could be authored to pierce everything on its
line. The attribute still clamped the Inspector to 1, so the behaviour existed and could
not be reached.
TargetLayer
Layer mask to filter targets.
[Tooltip("Layer mask to filter targets.")]
public LayerMask TargetLayer
Field Value
- LayerMask
Methods
SelectTargets(EventData)
Returns all UnityEngine.GameObjects hit by a raycast from the context in its forward direction.
public override IEnumerable<GameObject> SelectTargets(EventData eventData)
Parameters
eventDataEventDataThe event driving the selection.
Returns
- IEnumerable<GameObject>
An enumerable of UnityEngine.GameObjects hit by the ray, or empty if context is null.