How can I get the bounds size of a game object in an lod group? I tried modifying code that I found here: link text
Snippet of my C# script:
but it doesn't work. I get the following error at runtime:
Am I allowed to use stuff from the UnityEditor namespace from a game script? In my game, I build levels on the fly using different prefabs. Some are simple walls, and others are complex and have an lod group. The simple walls work fine. AFAIK, I only need to get the bounds of the first lod level as the lesser levels have meshes that are the same dimensions. Can someone please tell me how to do this? Thanks.
Ok, so I found a simple way to do this. In my case, the object m_wall is a prefab in a script set through the inspector, so I need to instantiate a dummy object first. Then to get the bounds I get a renderer from one of the children by calling GetComponentInChildren and pull the bounds from the renderer. Here is a code snippet from my game:
EDIT: For sake of completeness, the above only works for a single object. I have other prefabs that I build by combining multiple prefabs together under a single parent. In that case, things go horribly wrong. When I use those models I have to manually calculate the bounds and so the code for that looks like this: