BoxCollider size

Why this don’t work

BoxCollider col = go.AddComponent<BoxCollider();
col.size.z = 0.01f;

Instead I must do this in that way:

Vector3 colSize = col.size;
colSize.z = 0.01f;
col.size = colSize;

The reason is that size is a struct and not a class and so the value is passed by value and not by reference. When you do col.size you have a copy of the size so changing its z affects the copy which is then discarded.