GetPixelsToUnits() public static method

public static GetPixelsToUnits ( Sprite sprite ) : float
sprite UnityEngine.Sprite
return float
コード例 #1
0
ファイル: ResizeHandler.cs プロジェクト: MaxEden/RagePixel2
        private void ShiftTransformAfterResize(Transform transform, Sprite sprite, int oldWidth, int oldHeight, int newWidth, int newHeight)
        {
            Vector2 pivot         = Utility.GetNormalizedPivot(sprite);
            float   pixelsToUnits = Utility.GetPixelsToUnits(sprite);
            Vector2 sizeDelta     = new Vector2(newWidth - oldWidth, newHeight - oldHeight);

            transform.Translate(Vector2.Scale(sizeDelta, pivot) / pixelsToUnits, Space.Self);
        }