https://github.com/nomnomab/RaycastVisualization
This asset allows users to view raycasts as the user fires them.
https://github.com/nomnomab/RaycastVisualization
editor helper raycasting tools unity utility visuals
Last synced: 7 months ago
JSON representation
This asset allows users to view raycasts as the user fires them.
- Host: GitHub
- URL: https://github.com/nomnomab/RaycastVisualization
- Owner: nomnomab
- Created: 2021-08-05T00:23:03.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-07-01T14:40:06.000Z (over 1 year ago)
- Last Synced: 2024-11-10T16:46:34.165Z (12 months ago)
- Topics: editor, helper, raycasting, tools, unity, utility, visuals
- Language: C#
- Homepage:
- Size: 26.3 MB
- Stars: 152
- Watchers: 3
- Forks: 13
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

This asset allows users to view raycasts as the user fires them.
Supports both the 2D and 3D api.
## GIF Examples Of All Visuals
3D API (click to expand)
#### Raycast / Linecast

#### RaycastAll / RaycastNonAlloc

#### CapsuleCast

#### CapsuleCastAll / CapsuleCastNonAlloc

#### CheckCapsule

#### OverlapCapsule / OverlapCapsuleNonAlloc

#### BoxCast

#### BoxCastAll / BoxCastNonAlloc

#### CheckBox

#### OverlapBox / OverlapBoxNonAlloc

#### SphereCast

#### SphereCastAll / SphereCastNonAlloc

#### CheckSphere

#### OverlapSphere / OverlapSphereNonAlloc

#### Compute Penetration

#### Closest Point

2D API (click to expand)
#### Raycast

#### RaycastAll / RaycastAll / RaycastNonAlloc

#### CapsuleCast

#### CapsuleCastAll / CapsuleCastAll / CapsuleCastNonAlloc

#### OverlapCapsule

#### OverlapCapsuleAll / OverlapCapsuleNonAlloc

#### BoxCast

#### BoxCastAll / BoxCastAll / BoxCastNonAlloc

#### OverlapBox

#### OverlapBoxAll / OverlapBoxNonAlloc

#### CircleCast

#### CircleCastAll / CircleCastAll / CircleCastNonAlloc

#### OverlapCircle

#### OverlapCircleAll / OverlapCircleNonAlloc

#### OverlapPoint

#### OverlapPointAll / OverlapPointNonAlloc

#### OverlapArea

#### OverlapAreaAll / OverlapAreaNonAlloc

#### OverlapCollider

#### Closest Point

#### Distance

#### GetContacts

#### GetContacts (points)

#### IsTouching

#### IsTouchingLayers

#### GetRayIntersection

#### GetRayIntersectionAll / GetRayIntersectionNonAlloc

## Installation
#### Using Unity Package Manager
1. Open the Package Manager from `Window/Package Manager`
2. Click the '+' button in the top-left of the window
3. Click 'Add package from git URL'
4. Provide the URL of this git repository: https://github.com/nomnomab/RaycastVisualization.git
5. Click the 'add' button
## Usage
To get a visual to show up for a physics call simply do the following:
#### For 3D:
- Replace `Physics.` with `VisualPhysics.`.
#### For 2D:
- Replace `Physics2D.` with `VisualPhysics2D.`.
- Some 2D functions rely more on a 3D perspective in the editor depending on the orientation of the casts.
```csharp
// Example
void SomeFunction() {
if (VisualPhysics.Raycast(position, direction)) {
Debug.Log("Hit!");
}
}
```
#### API Switching:
You can also use a trick to automatically swap between the two APIs (useful for when you want to use the visual API in the editor, but the normal API in builds):
- Using `VisualPhysics` in a build will use the normal `Physics` API, however the method call may not be inlined depending on the compiler's mood.
```csharp
#if UNITY_EDITOR
using Physics = Nomnom.RaycastVisualization.VisualPhysics;
#else
using Physics = UnityEngine.Physics;
#endif
void SomeFunction() {
if (Physics.Raycast(position, direction)) {
Debug.Log("Hit!");
}
}
```
#### Defining a Visual's Lifetime:
Using `VisualLifetime.Create(seconds)` you can define how long a cast will display for:
```csharp
// will display the raycast for a second, rather than a single frame
using (VisualLifetime.Create(1f)) {
if (VisualPhysics.Raycast(position, direction)) {
Debug.Log("Hit");
}
}
```
#### User Options
The user options are located under `Edit/Preferences/RaycastVisualization`
