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); }