{
public class Gizmo6FacesBox
const float k_HandleSizeCoef = 0.05f;
protected enum NamedFace { Right, Top, Front, Left, Bottom, Back }
protected enum Element { Face, SelectedFace, Handle }
m_faceColorsSelected = value;
}
Color[] m_faceColors;
Gizmos.color = colorGizmo;
Debug.Log("center: " + center);
Debug.Log("size: " + size);
Debug.Log("color: " + colorGizmo);
//Note: Handles.Slider not allow to use a specific ControlID.
//Thus Slider1D is used (with reflection)
static PropertyInfo k_scale = Type.GetType("UnityEditor.SnapSettings, UnityEditor").GetProperty("scale");
static Type k_Slider1D = Type.GetType("UnityEditorInternal.Slider1D, UnityEditor");
static MethodInfo k_Slider1D_Do = k_Slider1D
public void DrawHandle()
Type k_Slider1D = Type.GetType("UnityEditorInternal.Slider1D, UnityEditor");
MethodInfo k_Slider1D_Do = k_Slider1D
.GetMethod(
"Do",
BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public,
null,
CallingConventions.Any,
new[] { typeof(int), typeof(Vector3), typeof(Vector3), typeof(float), typeof(Handles.CapFunction), typeof(float) },
null);
float handleSizeCoef = 0.05f;
//Draw Handles
EditorGUI.BeginChangeCheck();
Vector3 leftPosition = center + size.x * .5f * Vector3.left;
Vector3 frontPosition = center + size.z * .5f * Vector3.forward;
Vector3 backPosition = center + size.z * .5f * Vector3.back;
float snapScale = (float)k_scale.GetValue(null, null);
using (new Handles.DrawingScope(GetColor(NamedFace.Left, Element.Handle)))
leftPosition,
Vector3.left,
HandleUtility.GetHandleSize(leftPosition) * handleSizeCoef,
HandleUtility.GetHandleSize(leftPosition) * k_HandleSizeCoef,
new Handles.CapFunction(Handles.DotHandleCap),
snapScale
});
m_ControlIDs[(int)NamedFace.Right],
rightPosition,
HandleUtility.GetHandleSize(rightPosition) * handleSizeCoef,
HandleUtility.GetHandleSize(rightPosition) * k_HandleSizeCoef,
m_ControlIDs[(int)NamedFace.Top],
topPosition,
Vector3.up,
HandleUtility.GetHandleSize(topPosition) * handleSizeCoef,
HandleUtility.GetHandleSize(topPosition) * k_HandleSizeCoef,
m_ControlIDs[(int)NamedFace.Bottom],
bottomPosition,
Vector3.down,
HandleUtility.GetHandleSize(bottomPosition) * handleSizeCoef,
HandleUtility.GetHandleSize(bottomPosition) * k_HandleSizeCoef,
m_ControlIDs[(int)NamedFace.Front],
frontPosition,
Vector3.forward,
HandleUtility.GetHandleSize(frontPosition) * handleSizeCoef,
HandleUtility.GetHandleSize(frontPosition) * k_HandleSizeCoef,
m_ControlIDs[(int)NamedFace.Back],
backPosition,
Vector3.back,
HandleUtility.GetHandleSize(backPosition) * handleSizeCoef,
HandleUtility.GetHandleSize(backPosition) * k_HandleSizeCoef,
Color colorGizmo = Gizmos.color;
base.DrawHull(selected);
//if selected, also draw handle displacement here
//if selected, also draw handle distance to container here
if (selected)
Vector3 centerDiff = center - m_container.center;
Gizmos.color = GetColor(NamedFace.Back, Element.Handle);
Gizmos.DrawLine(m_container.center + zRecal + m_container.size.z * .5f * Vector3.back, center + size.z * .5f * Vector3.back);