internal static Vector3 SideSlider(int id, Vector3 position, Vector3 sideVector, Vector3 direction, float size, Handles.DrawCapFunction drawFunc, float snap, float bias) { Event current = Event.current; Vector3 normalized = Vector3.Cross(sideVector, direction).normalized; Vector3 vector = Handles.Slider2D(id, position, normalized, direction, sideVector, 0f, drawFunc, Vector2.one * snap); vector = position + Vector3.Project(vector - position, direction); EventType type = current.type; if (type != EventType.Repaint) { if (type != EventType.Layout) { if (type == EventType.MouseMove) { RectHandles.DetectCursorChange(id); } } else { Vector3 normalized2 = sideVector.normalized; HandleUtility.AddControl(id, HandleUtility.DistanceToLine(position + sideVector * 0.5f - normalized2 * size * 2f, position - sideVector * 0.5f + normalized2 * size * 2f) - bias); } } else if ((HandleUtility.nearestControl == id && GUIUtility.hotControl == 0) || GUIUtility.hotControl == id) { RectHandles.HandleDirectionalCursor(position, normalized, direction); } return(vector); }
internal static Vector3 SideSlider(int id, Vector3 position, Vector3 sideVector, Vector3 direction, float size, Handles.DrawCapFunction drawFunc, float snap, float bias) { Event current = Event.current; Vector3 normalized1 = Vector3.Cross(sideVector, direction).normalized; Vector3 vector3_1 = Handles.Slider2D(id, position, normalized1, direction, sideVector, 0.0f, drawFunc, Vector2.one * snap); Vector3 vector3_2 = position + Vector3.Project(vector3_1 - position, direction); switch (current.type) { case EventType.Repaint: if (HandleUtility.nearestControl == id && GUIUtility.hotControl == 0 || GUIUtility.hotControl == id) { RectHandles.HandleDirectionalCursor(position, normalized1, direction); break; } break; case EventType.Layout: Vector3 normalized2 = sideVector.normalized; HandleUtility.AddControl(id, HandleUtility.DistanceToLine(position + sideVector * 0.5f - normalized2 * size * 2f, position - sideVector * 0.5f + normalized2 * size * 2f) - bias); break; case EventType.MouseMove: RectHandles.DetectCursorChange(id); break; } return(vector3_2); }
public static float RotationSlider(int id, Vector3 cornerPos, float rotation, Vector3 pivot, Vector3 handleDir, Vector3 outwardsDir1, Vector3 outwardsDir2, float handleSize, Handles.DrawCapFunction drawFunc, Vector2 snap) { Vector3 b = outwardsDir1 + outwardsDir2; Vector2 vector = HandleUtility.WorldToGUIPoint(cornerPos); Vector2 b2 = (HandleUtility.WorldToGUIPoint(cornerPos + b) - vector).normalized * 15f; RectHandles.RaycastGUIPointToWorldHit(vector + b2, new Plane(handleDir, cornerPos), out cornerPos); Event current = Event.current; Vector3 a = Handles.Slider2D(id, cornerPos, handleDir, outwardsDir1, outwardsDir2, handleSize, drawFunc, Vector2.zero); if (current.type == EventType.MouseMove) { RectHandles.DetectCursorChange(id); } if (current.type == EventType.Repaint && ((HandleUtility.nearestControl == id && GUIUtility.hotControl == 0) || GUIUtility.hotControl == id)) { Rect position = new Rect(current.mousePosition.x - 100f, current.mousePosition.y - 100f, 200f, 200f); EditorGUIUtility.AddCursorRect(position, MouseCursor.RotateArrow); } return(rotation - RectHandles.AngleAroundAxis(a - pivot, cornerPos - pivot, handleDir)); }
internal static Vector3 CornerSlider(int id, Vector3 cornerPos, Vector3 handleDir, Vector3 outwardsDir1, Vector3 outwardsDir2, float handleSize, Handles.DrawCapFunction drawFunc, Vector2 snap) { Event current = Event.current; Vector3 vector3 = Handles.Slider2D(id, cornerPos, handleDir, outwardsDir1, outwardsDir2, handleSize, drawFunc, snap); switch (current.type) { case EventType.MouseMove: RectHandles.DetectCursorChange(id); break; case EventType.Repaint: if (HandleUtility.nearestControl == id && GUIUtility.hotControl == 0 || GUIUtility.hotControl == id) { RectHandles.HandleDirectionalCursor(cornerPos, handleDir, outwardsDir1 + outwardsDir2); break; } break; } return(vector3); }
internal static Vector3 CornerSlider(int id, Vector3 cornerPos, Vector3 handleDir, Vector3 outwardsDir1, Vector3 outwardsDir2, float handleSize, Handles.DrawCapFunction drawFunc, Vector2 snap) { Event current = Event.current; Vector3 result = Handles.Slider2D(id, cornerPos, handleDir, outwardsDir1, outwardsDir2, handleSize, drawFunc, snap); EventType type = current.type; if (type != EventType.MouseMove) { if (type == EventType.Repaint) { if ((HandleUtility.nearestControl == id && GUIUtility.hotControl == 0) || GUIUtility.hotControl == id) { RectHandles.HandleDirectionalCursor(cornerPos, handleDir, outwardsDir1 + outwardsDir2); } } } else { RectHandles.DetectCursorChange(id); } return(result); }