UnityEditor.RectTool.GetRectPointInWorld C# (CSharp) Method

GetRectPointInWorld() private static method

private static GetRectPointInWorld ( Rect rect, Vector3 pivot, Quaternion rotation, int xHandle, int yHandle ) : Vector3
rect UnityEngine.Rect
pivot Vector3
rotation UnityEngine.Quaternion
xHandle int
yHandle int
return Vector3
        private static Vector3 GetRectPointInWorld(Rect rect, Vector3 pivot, Quaternion rotation, int xHandle, int yHandle)
        {
            Vector3 vector;
            vector = (Vector3) new Vector2(vector.x = Mathf.Lerp(rect.xMin, rect.xMax, xHandle * 0.5f), vector.y = Mathf.Lerp(rect.yMin, rect.yMax, yHandle * 0.5f));
            return (((Vector3) (rotation * vector)) + pivot);
        }

Usage Example

示例#1
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);
        }
All Usage Examples Of UnityEditor.RectTool::GetRectPointInWorld