-
-
Notifications
You must be signed in to change notification settings - Fork 242
/
MyGizmos.cs
31 lines (27 loc) · 1.03 KB
/
MyGizmos.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using UnityEngine;
namespace MyBox
{
public static class MyGizmos
{
public static void DrawArrow(Vector3 from, Vector3 direction, float headLength = 0.25f, float headAngle = 20.0f)
{
#if UNITY_EDITOR
Gizmos.DrawRay(from, direction);
Vector3 right = Quaternion.LookRotation(direction) * Quaternion.Euler(180 + headAngle, 0, 180 + headAngle) * new Vector3(0, 0, 1);
Vector3 left = Quaternion.LookRotation(direction) * Quaternion.Euler(180 - headAngle, 0, 180 - headAngle) * new Vector3(0, 0, 1);
Gizmos.DrawRay(from + direction, right * headLength);
Gizmos.DrawRay(from + direction, left * headLength);
#endif
}
#if UNITY_PHYSICS2D_ENABLED
public static void DrawBoxCollider2D(BoxCollider2D collider, bool fill = true)
{
var target = collider.transform;
Gizmos.matrix = Matrix4x4.TRS(target.position, target.rotation, target.lossyScale);
if (fill) Gizmos.DrawCube(collider.offset, collider.size);
else Gizmos.DrawWireCube(collider.offset, collider.size);
Gizmos.matrix = Matrix4x4.identity;
}
#endif
}
}