Only check collision of certain collider

Hello, i have following problem,

I have an object with a box collider and a sphere collider.
Now my question, is it possible to differ from these two colliders on a collision
information, like OnCollisionEnter, so that for example somthing happens only if
an other object enters the box collider and ignores the sphere collider?

I know that i could also make empty game objects and send information to parent object,
but in my case it would be better to have it on the same object.

That depends on your definition of ‘better’. If you can’t do it, it’s not better. You could try and see if you get the event, and see if you can determine which type of collider it was (use GetType() maybe?)

You can’t put 2 colliders on the same object- flat doesn’t work. The only way is to use a compound collider!

However, that makes it easier to differentiate between the two- on your top object, have a script with

void OnBoxCollisionEnter(Collision collision)
{
    // Do stuff
}

void OnSphereCollisionEnter(Collision collision)
{
    // Do other stuff
}

Then, on your box collider put a script with

void OnCollisionEnter(Collision collision)
{
    SendMessageUpwards("OnBoxCollisionEnter", collision);
}

And on your sphere collider-

void OnCollisionEnter(Collision collision)
{
    SendMessageUpwards("OnSphereCollisionEnter", collision);
}

This way you can split the code up between the two different colliders, while still having them on the same compound rigidbody! (I assume it’s a compound rigidbody)