DistanceToRectangleInternal() static private method

static private DistanceToRectangleInternal ( Vector3 position, Quaternion rotation, Vector2 size ) : float
position Vector3
rotation UnityEngine.Quaternion
size Vector2
return float
 private static void HandleCap(int controlID, Vector3 position, GUIStyle guiStyle, EventType eventType)
 {
     if (eventType != EventType.Layout)
     {
         if (eventType == EventType.Repaint)
         {
             Handles.BeginGUI();
             position = HandleUtility.WorldToGUIPoint(position);
             float fixedWidth  = guiStyle.fixedWidth;
             float fixedHeight = guiStyle.fixedHeight;
             Rect  position2   = new Rect(position.x - fixedWidth / 2f, position.y - fixedHeight / 2f, fixedWidth, fixedHeight);
             guiStyle.Draw(position2, GUIContent.none, controlID);
             Handles.EndGUI();
         }
     }
     else
     {
         HandleUtility.AddControl(controlID, HandleUtility.DistanceToRectangleInternal(position, Quaternion.identity, Vector2.zero));
     }
 }
Example #2
0
        static void HandleCap(int controlID, Vector3 position, GUIStyle guiStyle, EventType eventType)
        {
            switch (eventType)
            {
            case EventType.Layout:
                HandleUtility.AddControl(controlID, HandleUtility.DistanceToRectangleInternal(position, Quaternion.identity, Vector2.zero));
                break;

            case EventType.Repaint:
                Handles.BeginGUI();

                position = HandleUtility.WorldToGUIPoint(position);
                var w = guiStyle.fixedWidth;
                var h = guiStyle.fixedHeight;
                var r = new Rect(position.x - w / 2f, position.y - h / 2f, w, h);

                guiStyle.Draw(r, GUIContent.none, controlID);
                Handles.EndGUI();
                break;
            }
        }
        internal static void RectangleHandleCap(int controlID, Vector3 position, Quaternion rotation, Vector2 size, EventType eventType)
        {
            switch (eventType)
            {
            case (EventType.Layout):
                // TODO: Create DistanceToRectangle
                HandleUtility.AddControl(controlID, HandleUtility.DistanceToRectangleInternal(position, rotation, size));
                break;

            case (EventType.Repaint):
                Vector3 sideways = rotation * new Vector3(size.x, 0, 0);
                Vector3 up       = rotation * new Vector3(0, size.y, 0);
                s_RectangleHandlePointsCache[0] = position + sideways + up;
                s_RectangleHandlePointsCache[1] = position + sideways - up;
                s_RectangleHandlePointsCache[2] = position - sideways - up;
                s_RectangleHandlePointsCache[3] = position - sideways + up;
                s_RectangleHandlePointsCache[4] = position + sideways + up;
                Handles.DrawPolyLine(s_RectangleHandlePointsCache);
                break;
            }
        }
Example #4
0
		public static float DistanceToRectangle(Vector3 position, Quaternion rotation, float size)
		{
			return HandleUtility.DistanceToRectangleInternal(position, rotation, new Vector2(size, size));
		}