Enable Custom Gizmos in Unity3d Editor
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(MeshFilter))]
[ExecuteInEditMode]
public class GizmosTarget : MonoBehaviour {
public enum GizmoType {
Sphere, Cube
};
public float size = 0.3f;
public Color normalColor = Color.white;
public Color selectedColor = Color.red;
public GizmoType gizmoType = GizmoType.Sphere;
void OnDrawGizmos(){
Gizmos.color = normalColor;
switch(gizmoType)
{
case GizmoType.Cube:
Gizmos.DrawWireCube(transform.position, new Vector3( size, size, size) );
break;
case GizmoType.Sphere:
Gizmos.DrawWireSphere(transform.position, size);
break;
}
}
void OnDrawGizmosSelected() {
Gizmos.color = selectedColor;
switch(gizmoType)
{
case GizmoType.Cube:
Gizmos.DrawWireCube(transform.position, new Vector3( size, size, size) );
break;
case GizmoType.Sphere:
Gizmos.DrawWireSphere(transform.position, size);
break;
}
}
}