Scaling a rotated object in global Y

In my game I am having a bouncing ball over platforms / sidescroller, and during it’s bounces it rotates as it’s having a rigidbody, with bounce material.

Now I want to build with a raycasthit, that if the ball bounces onto something underneath it, that it is going to squish, or be scaled alittle done in 1 axes. If the ball’s local Y is similar to the global Y, this is no problem and is working perfectly, though when the ball rotates around it’s axes I want the ball still to be scaled in global Y coordinates, no matter how it is being rotated. Does anyone have any idea how to fix this, or a workaround?

using UnityEngine;
using System.Collections;

public class raycasthit : MonoBehaviour {
	RaycastHit  hit = new  RaycastHit();
	Vector3 dir;
	public float distance = 3;
	public float scaleTo = 0.90f;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		dir = new Vector3(0,-1,0);

		Debug.DrawRay(transform.position,dir*distance,Color.green);

		
		if(Physics.Raycast(transform.position,dir,out hit,distance)){
			transform.localScale = new Vector3(scaleTo, scaleTo, scaleTo);
		}
		else{
			transform.localScale = new Vector3(1f, 1f, 1f);
		}
	}
}

Thanks in advance!

One hackish solution is to make the ball a child of an empty game object. The empty game object must have rotation of (0,0,0). Scale the empty game object’s ‘y’ to scale the ball on the global ‘y’.