RotationSlider() public static méthode

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
Résultat float
        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);
        }
Exemple #2
0
        private static Quaternion RotationHandlesGUI(Rect rect, Vector3 pivot, Quaternion rotation)
        {
            Vector3 eulerAngles = rotation.eulerAngles;

            for (int i = 0; i <= 2; i += 2)
            {
                for (int j = 0; j <= 2; j += 2)
                {
                    Vector3 position   = GetRectPointInWorld(rect, pivot, rotation, i, j);
                    float   handleSize = 0.05f * HandleUtility.GetHandleSize(position);
                    int     controlID  = GUIUtility.GetControlID(s_RotationHandlesHash, FocusType.Passive);
                    if ((GUI.color.a > 0f) || (GUIUtility.hotControl == controlID))
                    {
                        EditorGUI.BeginChangeCheck();
                        Vector3 vector3 = (Vector3)((rotation * Vector3.right) * (i - 1));
                        Vector3 vector4 = (Vector3)((rotation * Vector3.up) * (j - 1));
                        float   num5    = RectHandles.RotationSlider(controlID, position, eulerAngles.z, pivot, (Vector3)(rotation * Vector3.forward), vector3, vector4, handleSize, null, Vector2.zero);
                        if (EditorGUI.EndChangeCheck())
                        {
                            if (Event.current.shift)
                            {
                                num5 = (Mathf.Round((num5 - eulerAngles.z) / 15f) * 15f) + eulerAngles.z;
                            }
                            eulerAngles.z = num5;
                            rotation      = Quaternion.Euler(eulerAngles);
                        }
                    }
                }
            }
            return(rotation);
        }
Exemple #3
0
        private static Quaternion RotationHandlesGUI(Rect rect, Vector3 pivot, Quaternion rotation)
        {
            Vector3 eulerAngles = rotation.eulerAngles;

            for (int i = 0; i <= 2; i += 2)
            {
                for (int j = 0; j <= 2; j += 2)
                {
                    Vector3 rectPointInWorld = RectTool.GetRectPointInWorld(rect, pivot, rotation, i, j);
                    float   handleSize       = 0.05f * HandleUtility.GetHandleSize(rectPointInWorld);
                    int     controlID        = GUIUtility.GetControlID(RectTool.s_RotationHandlesHash, FocusType.Passive);
                    if (GUI.color.a > 0f || GUIUtility.hotControl == controlID)
                    {
                        EditorGUI.BeginChangeCheck();
                        Vector3 outwardsDir  = rotation * Vector3.right * (float)(i - 1);
                        Vector3 outwardsDir2 = rotation * Vector3.up * (float)(j - 1);
                        float   num          = RectHandles.RotationSlider(controlID, rectPointInWorld, eulerAngles.z, pivot, rotation * Vector3.forward, outwardsDir, outwardsDir2, handleSize, null, Vector2.zero);
                        if (EditorGUI.EndChangeCheck())
                        {
                            if (Event.current.shift)
                            {
                                num = Mathf.Round((num - eulerAngles.z) / 15f) * 15f + eulerAngles.z;
                            }
                            eulerAngles.z = num;
                            rotation      = Quaternion.Euler(eulerAngles);
                        }
                    }
                }
            }
            return(rotation);
        }
Exemple #4
0
        private static Quaternion RotationHandlesGUI(Rect rect, Vector3 pivot, Quaternion rotation)
        {
            Vector3 eulerAngles = rotation.eulerAngles;
            int     xHandle     = 0;

            while (xHandle <= 2)
            {
                int yHandle = 0;
                while (yHandle <= 2)
                {
                    Vector3 rectPointInWorld = RectTool.GetRectPointInWorld(rect, pivot, rotation, xHandle, yHandle);
                    float   handleSize       = 0.05f * HandleUtility.GetHandleSize(rectPointInWorld);
                    int     controlId        = GUIUtility.GetControlID(RectTool.s_RotationHandlesHash, FocusType.Passive);
                    if ((double)GUI.color.a > 0.0 || GUIUtility.hotControl == controlId)
                    {
                        EditorGUI.BeginChangeCheck();
                        Vector3 outwardsDir1 = rotation * Vector3.right * (float)(xHandle - 1);
                        Vector3 outwardsDir2 = rotation * Vector3.up * (float)(yHandle - 1);
                        float   num          = RectHandles.RotationSlider(controlId, rectPointInWorld, eulerAngles.z, pivot, rotation * Vector3.forward, outwardsDir1, outwardsDir2, handleSize, (Handles.DrawCapFunction)null, Vector2.zero);
                        if (EditorGUI.EndChangeCheck())
                        {
                            if (Event.current.shift)
                            {
                                num = Mathf.Round((float)(((double)num - (double)eulerAngles.z) / 15.0)) * 15f + eulerAngles.z;
                            }
                            eulerAngles.z = num;
                            rotation      = Quaternion.Euler(eulerAngles);
                        }
                    }
                    yHandle += 2;
                }
                xHandle += 2;
            }
            return(rotation);
        }