Created
February 3, 2021 12:29
-
-
Save nothke/5b0ca7bf89adf656954f02bbcd6590f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public static class GizmoUtils | |
{ | |
public static void DrawCircle(Vector3 pos, Vector3 forward, float radius) | |
{ | |
#if UNITY_EDITOR | |
UnityEditor.Handles.color = Gizmos.color; | |
UnityEditor.Handles.CircleHandleCap( | |
-1, pos, Quaternion.LookRotation(forward), radius, EventType.Repaint); | |
#endif | |
} | |
public static void DrawLattice(Vector3 point, Vector3Int dimension) | |
{ | |
#if UNITY_EDITOR | |
for (int y = 0; y < dimension.y + 1; y++) | |
{ | |
for (int x = 0; x < dimension.x + 1; x++) | |
{ | |
Gizmos.DrawLine( | |
point + new Vector3(x, y, 0), | |
point + new Vector3(x, y, dimension.z)); | |
} | |
for (int z = 0; z < dimension.z + 1; z++) | |
{ | |
Gizmos.DrawLine( | |
point + new Vector3(0, y, z), | |
point + new Vector3(dimension.x, y, z)); | |
} | |
} | |
for (int x = 0; x < dimension.x + 1; x++) | |
{ | |
for (int z = 0; z < dimension.z + 1; z++) | |
{ | |
Gizmos.DrawLine( | |
point + new Vector3(x, 0, z), | |
point + new Vector3(x, dimension.y, z)); | |
} | |
} | |
#endif | |
} | |
public static void DrawLattice(Transform relativeTo, Vector3 point, Vector3Int dimension) | |
{ | |
#if UNITY_EDITOR | |
point -= relativeTo.position; | |
for (int y = 0; y < dimension.y + 1; y++) | |
{ | |
for (int x = 0; x < dimension.x + 1; x++) | |
{ | |
Gizmos.DrawLine( | |
point + relativeTo.TransformPoint(new Vector3(x, y, 0)), | |
point + relativeTo.TransformPoint(new Vector3(x, y, dimension.z))); | |
} | |
for (int z = 0; z < dimension.z + 1; z++) | |
{ | |
Gizmos.DrawLine( | |
point + relativeTo.TransformPoint(new Vector3(0, y, z)), | |
point + relativeTo.TransformPoint(new Vector3(dimension.x, y, z))); | |
} | |
} | |
for (int x = 0; x < dimension.x + 1; x++) | |
{ | |
for (int z = 0; z < dimension.z + 1; z++) | |
{ | |
Gizmos.DrawLine( | |
point + relativeTo.TransformPoint(new Vector3(x, 0, z)), | |
point + relativeTo.TransformPoint(new Vector3(x, dimension.y, z))); | |
} | |
} | |
#endif | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment