Set bounds of collider added at runtime

I am trying to add the bounds of a collider that is added at runtime. For some reason, I am unable to see updates to center or size or extent when I set it using the below:

var p = new GameObject("box");
p.AddComponent(BoxCollider);
p.collider.bounds.center = Vector3(4.5,4.5,4.5);

.
.
.

The resulting collider shows up in the inspector, but the values are always default, i.e., center and size aren’t showing up as defined.

How do you set the bounds, center, and such of a collider added at runtime?

I don’t think you can assign the bounds of a collider directly. However, the collider itself has center and extents properties that you can assign. As an example:

	GameObject go = new GameObject();
    BoxCollider collider = go.AddComponent<BoxCollider>();
	collider.center = new Vector3(2, 2, 2);
	collider.extents = new Vector3(9, 12, 18);