Is there a component to have the size of gameobject ?

  • Hi, i’m making a script to check if my instantiate room have the same position.
  • My script put all gameobject with tag room and compare them 1 by 1 the transform they have.
  • But that only compare the first block position you can see on picture. I want to compare all the room area. So i’m looking for something easy if that exist before making another scrpit that put in array all position ob sub gameobject that compose a room.
  • ( cant do script with collider and trigger event because they are all with no rigidebody ).

Not sure if this will work for you, since I don’t see such components in your screenshot, so I’m not quite clear how you are drawing those meshes.

However, if you ARE using a MeshRenderer, for each room, you can use the BOUNDS member to get the (axis-aligned!!) total size and position of the room. The bounds returned by this function is in world-space. Unity - Scripting API: Renderer.bounds

If your room might be rotated (and therefore not be axis-aligned), you can use the rendered MESH’s bounds to get the model’s size and position in modelspace (which you can then transform to world space). Unity - Scripting API: Mesh.bounds

If you find you have lots of “bounds” values, that you need to combine: check out Unity - Scripting API: Bounds.Encapsulate (in particular the second version, that takes a bounds as a parameter- though this would only work for axis aligned bounds)