UnityEditor.RectHandles.RotationSlider C# (CSharp) Method

RotationSlider() public static method

public static RotationSlider ( int id, Vector3 cornerPos, float rotation, Vector3 pivot, Vector3 handleDir, Vector3 outwardsDir1, Vector3 outwardsDir2, float handleSize, Handles drawFunc, Vector2 snap ) : float
id int
cornerPos Vector3
rotation float
pivot Vector3
handleDir Vector3
outwardsDir1 Vector3
outwardsDir2 Vector3
handleSize float
drawFunc Handles
snap Vector2
return float
        public static float RotationSlider(int id, Vector3 cornerPos, float rotation, Vector3 pivot, Vector3 handleDir, Vector3 outwardsDir1, Vector3 outwardsDir2, float handleSize, Handles.CapFunction drawFunc, Vector2 snap)
        {
            Vector3 vector = outwardsDir1 + outwardsDir2;
            Vector2 vector2 = HandleUtility.WorldToGUIPoint(cornerPos);
            Vector2 vector3 = HandleUtility.WorldToGUIPoint(cornerPos + vector) - vector2;
            vector3 = (Vector2) (vector3.normalized * 15f);
            RaycastGUIPointToWorldHit(vector2 + vector3, new Plane(handleDir, cornerPos), out cornerPos);
            Event current = Event.current;
            Vector3 vector4 = Handles.Slider2D(id, cornerPos, handleDir, outwardsDir1, outwardsDir2, handleSize, drawFunc, Vector2.zero);
            if (current.type == EventType.MouseMove)
            {
                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 - AngleAroundAxis(vector4 - pivot, cornerPos - pivot, handleDir));
        }

Usage Example

示例#1
0
        static Quaternion RotationHandlesGUI(Rect rect, Vector3 pivot, Quaternion rotation)
        {
            Vector3 euler = rotation.eulerAngles;

            // Loop through the 4 corner handles
            for (int xHandle = 0; xHandle <= 2; xHandle += 2)
            {
                for (int yHandle = 0; yHandle <= 2; yHandle += 2)
                {
                    Vector3 curPos = GetRectPointInWorld(rect, pivot, rotation, xHandle, yHandle);

                    float size = 0.05f * HandleUtility.GetHandleSize(curPos);
                    int   id   = GUIUtility.GetControlID(s_RotationHandlesHash, FocusType.Passive);
                    if (GUI.color.a > 0 || GUIUtility.hotControl == id)
                    {
                        EditorGUI.BeginChangeCheck();
                        Vector3 outwardsA = rotation * Vector3.right * (xHandle - 1);
                        Vector3 outwardsB = rotation * Vector3.up * (yHandle - 1);
                        float   angle     = RectHandles.RotationSlider(id, curPos, euler.z, pivot, rotation * Vector3.forward, outwardsA, outwardsB, size, null, Vector2.zero);
                        if (EditorGUI.EndChangeCheck())
                        {
                            if (Event.current.shift)
                            {
                                angle = Mathf.Round((angle - euler.z) / 15f) * 15f + euler.z;
                            }
                            euler.z  = angle;
                            rotation = Quaternion.Euler(euler);
                        }
                    }
                }
            }
            return(rotation);
        }
All Usage Examples Of UnityEditor.RectHandles::RotationSlider