public static PixelToUV ( |
||
pixel | ||
sprite | ||
Résultat | Vector2 |
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); }
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); }
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(); } }