I\'m using the new 2d tools in Unity3d, and I have a game object with a 2d polygonal collider attached to it. I just want to understand how to get the width of this object! Why
There are two ways(at least) to get this.
var renderer = gameObject.GetComponent();
int width = renderer.bounds.size.x;
or
var collider2D= gameObject.GetComponent();
var collider = collider2D.collider; //Edit, thanks to Arttu's comment!
int width = collider.bounds.size.x;
For your 2D case, the former might be more appropriate.