unity collision layers code example
Example: unity check collider layer
function OnCollisionEnter(collision : Collision)
{
if (collision.collider.gameObject.layer == LayerMask.NameToLayer("LAYER_NAME"))
{
Debug.Log("Touched a rail");
}
}