UVToLocal() public static method

public static UVToLocal ( Vector2 uv, Sprite sprite ) : Vector3
uv Vector2
sprite UnityEngine.Sprite
return Vector3
示例#1
0
        public static Vector3 PixelToWorld(IntVector2 pixelPosition, Transform transform, Sprite sprite, bool clamp)
        {
            Vector2 uvPosition    = Utility.PixelToUV(pixelPosition, sprite, clamp);
            Vector3 localPosition = Utility.UVToLocal(uvPosition, sprite, clamp);
            Vector2 worldPosition = Utility.LocalToWorld(localPosition, transform);

            return(worldPosition);
        }
示例#2
0
        public static Vector2 PixelToScreen(IntVector2 pixelPosition, Transform transform, Sprite sprite, bool clamp)
        {
            Vector2 uvPosition     = Utility.PixelToUV(pixelPosition, sprite, clamp);
            Vector3 localPosition  = Utility.UVToLocal(uvPosition, sprite, clamp);
            Vector2 screenPosition = Utility.LocalToScreen(localPosition, transform);

            return(screenPosition);
        }
示例#3
0
        public void OnSceneGUI(RagePixelState state)
        {
            Initialize(state);

            Vector2 uvPos    = Utility.PixelToUV(m_Size, state.sprite, false);
            Vector3 localPos = Utility.UVToLocal(uvPos, state.sprite, false);
            Vector3 worldPos = Utility.LocalToWorld(localPos, state.transform);

            EditorGUI.BeginChangeCheck();
            worldPos = Handles.FreeMoveHandle(worldPos, Quaternion.identity, HandleUtility.GetHandleSize(worldPos) * 0.1f, Vector3.zero, Handles.RectangleCap);
            if (EditorGUI.EndChangeCheck())
            {
                localPos = Utility.WorldToLocal(worldPos, state.transform);
                uvPos    = Utility.LocalToUV(localPos, state.sprite, false);
                m_Size   = Utility.UVToPixel(uvPos, state.sprite, false);
                m_Size   = new IntVector2((int)Mathf.Clamp(m_Size.x, k_MinSize, k_MaxSize), (int)Mathf.Clamp(m_Size.y, k_MinSize, k_MaxSize));
                state.Repaint();
            }
        }