How I know the height of a gameobject?

Is there a way to know the height of an gameobject?

If I create 3 cubes on top of eachother, how do I know the height of each of them?

If your talking about the y axis.

transform.lossyScale.y

http://unity3d.com/support/documentation/ScriptReference/Transform-lossyScale.html

Well the easiest way is to draw a box around the object which encloses it on the x,y and z axis. If you want to do it that way check out Bounds.2.y

  • Edit:

I see you edited your question to only concern cubes. Since the default height of a cube is 1 unit, the height of three cubes on top of eachother is cube1.transform.localScale.y+cube2.transform.localScale.y+cube3.transform.localScale.y;.

Check out Measuring the length of Objects - Questions & Answers - Unity Discussions as well, which deals with the length of an object; a question analog to this one.

In short, if your GameObject has geometry that gets drawn, then it also has a MeshRenderer. If it has a MeshRenderer, then it also has a bounds-property, since MeshRenderer inherits from Renderer. If it has a bounds-property, then you always have access to its bounding box, which gives you the dimensions of the object.