Uninomicon

Documenting the dark corners of the Unity Engine.

User Tools

Site Tools


raycasthit2d

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
raycasthit2d [2021/05/05 16:53]
uninomiconadmin
raycasthit2d [2021/05/05 16:57] (current)
uninomiconadmin
Line 3: Line 3:
 ==== Casts Implicitly To a Bool ==== ==== Casts Implicitly To a Bool ====
 RaycastHit2D implements the C# [[https://forum.unity.com/threads/c-beginner-tips-1-your-friend-the-implicit-bool.185761/|implicit bool]] operator. This allows it to be used in an if statement to check whether a hit is found. RaycastHit2D implements the C# [[https://forum.unity.com/threads/c-beginner-tips-1-your-friend-the-implicit-bool.185761/|implicit bool]] operator. This allows it to be used in an if statement to check whether a hit is found.
 +<code csharp>
 +public static implicit operator bool(RaycastHit2D hit) => (Object) hit.collider != (Object) null;
 +</code>
 ++++ Example | ++++ Example |
 <code c#> <code c#>
raycasthit2d.txt ยท Last modified: 2021/05/05 16:57 by uninomiconadmin