collider error

I think this may be an error but I wanted to see if anybody else is seeing this.

here’s the code

var fadeMaterial = gameObject.Find("cubes").GetComponentInChildren(Transform);
		for (var materialToFade : Transform in fadeMaterial) {
			materialToFade.gameObject.AddComponent("CubeScript");
			materialToFade.gameObject.AddComponent("Rigidbody");
			materialToFade.gameObject.AddComponent("BoxCollider");
			materialToFade.gameObject.collider.size = Vector3(0.4,0.4,0.4);
			materialToFade.gameObject.rigidbody.useGravity = true;
      }

This is throwing an error for the size component. It is saying the ‘size’ is not a member of UnityEngine.Collider.

But size is a member (at least it works fine in regular unity and the manual shows it should work too)

can anybody repeat this for me?

thanks

Flash

Size isn’t a member of Collider; check the docs again. It’s a member of BoxCollider though. It only works in regular Unity if you use dynamic typing, which you can’t for the iPhone.

–Eric

Didn’t realize this was a typing error.

How do I access the boxcollider that’s on the children of “cubes”. (children - cube1, cube2, etc)

	var getBoxCollider = gameObject.Find("cubes").GetComponentInChildren(BoxCollider);
	for (var colliderToChange : BoxCollider in getBoxCollider) {
		colliderToChange.size = Vector3(0.4,0.4,0.4);
	}

gives me an IEnumerable error

Flash

You’re probably looking for GetComponentsInChildren.

–Eric