Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Getting the width/height of a rotated object

Discussion in 'Scripting' started by random1, Jun 30, 2013.

  1. random1

    random1

    Joined:
    Jun 19, 2013
    Posts:
    21
    I want to get the width(x) and height(z) of an object. This works fine using transform.lossyScale or transform.localScale when the object is unrotated, but the variables aren't updated when an object is rotated.

    So a 2*1 object when rotated 90 degrees becomes 1*2, but neither of those reflects that.

    So how do I get the width/height of a rotated object?
    Thanks.
     
  2. random1

    random1

    Joined:
    Jun 19, 2013
    Posts:
    21
    It seems that renderer.bounds is the way to go. (i.e. renderer.bounds.extent.x )