Skip to content

Instantly share code, notes, and snippets.

@olange
Forked from david-hodgetts/ShowMyTransforms.cs
Last active January 20, 2016 18:10
Show Gist options
  • Save olange/4df2e4c0489fd8ccfe12 to your computer and use it in GitHub Desktop.
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
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