LocalToUV() public static method

public static LocalToUV ( Vector3 localPosition, Sprite sprite ) : Vector2
localPosition Vector3
sprite UnityEngine.Sprite
return Vector2
示例#1
0
        public static Vector2 ScreenToUV(Vector2 screenPosition, Transform transform, Sprite sprite, bool clamp)
        {
            Vector3 localPosition = Utility.ScreenToLocal(screenPosition, transform);
            Vector2 uvPosition    = Utility.LocalToUV(localPosition, sprite, clamp);

            return(uvPosition);
        }
示例#2
0
        public static IntVector2 WorldToPixel(Vector2 worldPosition, Transform transform, Sprite sprite, bool clamp)
        {
            Vector3    localPosition = Utility.WorldToLocal(worldPosition, transform);
            Vector2    uvPosition    = Utility.LocalToUV(localPosition, sprite, clamp);
            IntVector2 pixelPosition = Utility.UVToPixel(uvPosition, sprite, clamp);

            return(pixelPosition);
        }
示例#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();
            }
        }