Version: 1.0.0
Author: egyhurka
License: MIT
EasyTrace is a lightweight and extensible utility for working with raycasts, debug drawing, and collision helpers in Unity.
All visual debug helpers (like
Debug.DrawLine,DrawRay,DrawSphere) only appear in the Unity Editor Scene View. They are invisible in builds, but the logic still executes.
- 🔍 Simple
Raycast,SphereCast, and screen-to-world tracing - 🧠 Debug visualization helpers (lines, spheres, points)
- 🧱 Static utility class - no setup needed
- 🖱️ Includes example MonoBehaviour (
EasyTrace.cs) for usage - 🎨 Debug options are optional and fully customizable
Just copy Trace.cs and (optionally) EasyTrace.cs into your Unity project.
| File | Description |
|---|---|
Trace.cs |
Static class for all tracing + debug |
EasyTrace.cs |
Example MonoBehaviour using Trace tools |
This project is licensed under the MIT License – feel free to use, modify, and distribute.
if (Trace.Forward(transform, 10f, Trace.DEFAULT_LAYER, out RaycastHit hit, true))
{
Debug.Log(hit.collider.name);
}if (Trace.FromScreenPoint(Camera.main, Input.mousePosition, 100f, Trace.DEFAULT_LAYER, out RaycastHit hit, true))
{
// Use hit.point, hit.normal, etc.
}// WARNING: You must **remove** the RaycastHit[] declaration here!
RaycastHit[] hits;
// The 'hits' array will be assigned by the FieldOfView method via the 'out' parameter.
Trace.FieldOfView(camera, 20f, layerMask, out hits, true);
Trace.RemoveSameHits(ref hits);if (Trace.Sphere(transform.position, 3f, Trace.DEFAULT_LAYER, out Collider[] hits, true))
{
foreach (var hit in hits)
Debug.Log("Nearby: " + hit.name);
}public static void DrawDebugRay(bool valid, float distance, Ray ray, RaycastHit hit, float duration = DEBUG_DRAW_DURATION)public static void DrawMovement(Vector3 lastPosition, Vector3 position, float duration, Color color)public static void DrawMovementSphere(Vector3 position, float duration, Color color)public static void DrawDebugSphere(Vector3 position, float radius, Color color, float duration = DEBUG_DRAW_DURATION, int segments = 20)public static void DrawHitPoint(Vector3 point, float size, Color color, float duration = DEBUG_DRAW_DURATION)public static void DrawFrustum(Camera camera, Color color, float duration = DEBUG_DRAW_DURATION)public static void DrawFovPlaneDistance(Camera camera, float distance, Color? color = null, float duration = DEBUG_DRAW_DURATION)