- Home /
Print bounds size.
I'm trying to print the Bounds.size of an object, but I can't find out how. This doesn't work:
function Update () {
Debug.Log(Collider.bounds.size);
}
I'd like some help with this.
Answer by AdamOwen · Jul 16, 2011 at 07:39 PM
You need to get the Collider component first:
Debug.Log(GetComponent(Collider).bounds.size);
Answer by Eric5h5 · Jul 16, 2011 at 07:59 PM
Lowercase c:
Debug.Log(collider.bounds.size);
"Collider" refers to the Collider class, "collider" is a shortcut for GetComponent(Collider).
Answer by Graham-Dunnett · Jul 16, 2011 at 07:20 PM
Debug.Log(Collider.bounds.size);
I've tried that. It says: " An instance of type 'UnityEngine.Collider' is required to access non static member 'bounds'." I already have a box collider on the object.
Your answer
Follow this Question
Related Questions
Matching an object's size 1 Answer
Can I use a raycast to retrieve information from the collider? 2 Answers
Is the bounds.size and the GetComponent.BoxCollider2D.size of a GameObject meant to be the same? 1 Answer
TextMesh.renderer.bounds.extents not 100% accurate? 2 Answers
How do I get the bounds of a sprite on its sprite atlas? 0 Answers