- Home /
Question by
slehmann101 · Feb 22, 2014 at 08:15 PM ·
c#gameobjectscalebounds
How should one resize a gameobject?
I have a gameobject which I would like to resize, the only way that i have seen to do this is via:
gameObject.transform.localScale = new Vector3(x,y,z);
however the problem with this is that when one does this it does not change the values of the bounds for example:
g.renderer.bounds.extents.x
or:
g.renderer.bounds.max.x
so how should this be done? I am using C#.
Comment
Answer by robertbu · Feb 22, 2014 at 08:41 PM
You should see a change in the extents. Start with a new scene and a cube. Add this script:
#pragma strict
function Start() {
Debug.Log(renderer.bounds);
transform.localScale = Vector3(.2,.2,.2);
Debug.Log(renderer.bounds);
}
Here is the output:
As you can see, the extents are 1/5 the size when the cube is 1/5 the size.
localscale.jpg
(15.6 kB)