Rigidbody with collision in runtime (c#)

I want to create collidable objects in runtime. So far i got:

cardObject = GameObject.CreatePrimitive(PrimitiveType.Cube);
cardObject.AddComponent<Rigidbody>();

I would like cardObject to:

  1. Use gravity
  2. Be collidable with other cardObjects (there are many in the scene)
  3. When two cardObjects collide, i would like a function to be called where i can gain access to the two objects.
  4. When two cardObjects collide, basic physics will apply, so that if the top card is placed on the edge of the bottom card, it will rest tilted on the bottom card.

Can someone help my out with this?

if you want to create quite complex runtime generated objects, you should create a prefab of one of thouse object that have all of your desired components and behaviours attached.
You simply can instantiate such an object by calling GameObject.Instantiate(YourPrefab);

Help on prefabs
just add a public member variable of type GameObject or Transform to your script. You simply can assign your prefab to your script by dragging it from your project view onto the variable in the inspector.

assuming you are using C#:

public class YourCreatorScript : MonoBehaviour
{
	public Transform CardPrefab;
	void CreateCard()
	{
		Transform MyNewCard = Instantiate(CardPrefab, Vector3.zero, Quaternion.identity);
		// Here you can modify the new object if you want
		MyNewCard.gameObject.name = "Card";
	}
[...]

if you have attached a rigidbody and a box colider to your object (in the prefab) physics is applied automatically. Just setup your object as you want in Unity and turn it into a prefab.
if you want to do some own stuff when your card collide with something, you have to create a second script and put that onto your object.
The cardscript can use OnCollisionEnter() or OnCollisionStay() to handle a collision.