Checking if object is in air or on ground?

How can I check if an object is on the ground? I have a cube.

What I do right now is cast a ray from cube's center to ground and if the distance is bigger than half the cube's size, it is set as in air. The problem is that if the cube is on an angular surface, it gets marked as being in air because the distance from cube's center to ground became bigger.

What's a good way to check if it's on the ground even on angular surface?

I use this:

var jumpHeight = 7.5;
var canJump = true;
var jumpCount = 0;

function Update () 
{

if(Input.GetButtonDown("Jump") && jumpCount == 0)
   {
   rigidbody.AddForce(Vector3.up * jumpHeight, ForceMode.Impulse);
   jumpCount = 1;
}
}

function OnCollisionEnter (hit : Collision)
{
if(hit.gameObject.tag == "Floor")
    {
    jumpCount = 0;
    }
}

If your ground is tagged "Floor" you should be able to jump no matter if it is a angular surface or not.

You could get the collision data and get the position of the collision and the normal and then if the rotation of the normal is less than some certain value you set then you set your canJump boolean to true.
(psuedocode-ish)

void OnCollisionEnter(Collision col) {
    if (col.normal <= maximumSurfaceNormal) {
        canJump = true;
    }
}

it's about "hit" function. look at "footstep sound" scripts, you can see it inside these scripts, about colliding with ground.

maybe: use a child cube, about a quarter of the height of the parent (so it doesn't collide too high up), with a length x width error-margin you prefer around the outside, that looks for collisions. When it's in collision with an object, you're (probably) on the ground.

Edit: oh, but make sure the bottom of the child cube is aligned with the bottom of the parent cube and offset downward by the error-margin.