Uninomicon

Documenting the dark corners of the Unity Engine.

User Tools

Site Tools


raycasthit2d

RaycastHit2D

Casts Implicitly To a Bool

RaycastHit2D implements the C# implicit bool operator. This allows it to be used in an if statement to check whether a hit is found.

public static implicit operator bool(RaycastHit2D hit) => (Object) hit.collider != (Object) null;

Example

raycasthit2d.txt · Last modified: 2021/05/05 16:57 by uninomiconadmin