-
-
Save olange/4df2e4c0489fd8ccfe12 to your computer and use it in GitHub Desktop.
An Unity Gizmo that displays the origin and orientation of a _game object_ when it is selected in the _Editor_, displaying its right/forward/up as red/blue/green axis
This file contains hidden or 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; | |
using System.Collections; | |
[ExecuteInEditMode] | |
public class ShowTransforms : MonoBehaviour { | |
private const float radius = 0.02f; | |
void OnDrawGizmosSelected() { | |
Vector3 origin, axisRight, axisForward, axisUp; | |
origin = transform.position; | |
axisRight = transform.position + transform.right; | |
axisForward = transform.position + transform.forward; | |
axisUp = transform.position + transform.up; | |
Gizmos.color = Color.white; | |
Gizmos.DrawSphere( origin, radius); | |
Gizmos.color = Color.red; | |
Gizmos.DrawLine( origin, axisRight); | |
Gizmos.DrawSphere( axisRight, radius); | |
Gizmos.color = Color.blue; | |
Gizmos.DrawLine( origin, axisForward); | |
Gizmos.DrawSphere( axisForward, radius); | |
Gizmos.color = Color.green; | |
Gizmos.DrawLine( origin, axisUp); | |
Gizmos.DrawSphere( axisUp, radius); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment