> For the complete documentation index, see [llms.txt](https://mindcodeinteractive.gitbook.io/easy-build-system/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mindcodeinteractive.gitbook.io/easy-build-system/reference/building-group.md).

# Building Group

Defines a group in the scene where [Building Parts](/easy-build-system/reference/building-part.md) are organized together by proximity.\
Updated automatically as [Building Parts](/easy-build-system/reference/building-part.md) are placed or destroyed in the scene.

***

### How Groups Work

Parts placed near each other are automatically grouped under a shared [Building Group](#how-groups-work).\
Groups represent structures like a house, a bridge, or a tower.\
They enable mesh batching for performance and allow collapse when a supporting part is removed.

Groups are created, merged, and split automatically by the Grouping System.\
The group's pivot is recentered to the geometric center of all its parts after each change.

A group can be marked as **Don't Destroy Group** to prevent it from being removed when empty. Dynamic groups (containing parts with Rigidbodies) update their bounds every frame.

***

### Scripting Examples

Get all registered groups:

```csharp
HashSet<BuildingGroup> groups = BuildingManager.Instance.GetRegisteredGroups;
```

Get a part's group:

```csharp
BuildingGroup group = myPart.AttachedGroup;
```

Get all parts in a group:

```csharp
List<BuildingPart> parts = group.GroupedParts;
```

Get the structure's bounding box:

```csharp
Bounds bounds = group.GroupBounds;
```

Batch and unbatch a group manually:

```csharp
group.BatchGroup();
group.UnbatchGroup();
```

Listen for group events:

```csharp
EventPublisher.Subscribe<BuildingGroupEvent.RegisteredEventArgs>(e =>
{
    Debug.Log("Group registered: " + e.Group.name);
});

EventPublisher.Subscribe<BuildingGroupEvent.UnregisteredEventArgs>(e =>
{
    Debug.Log("Group unregistered: " + e.Group.name);
});

EventPublisher.Subscribe<BuildingGroupEvent.UpdatedEventArgs>(e =>
{
    Debug.Log("Group updated, part: " + e.Part.Name);
});
```

***

### Debug Visualization

The [Building Group](#how-groups-work) draws a wireframe cube showing the group's bounding box around all its parts.

Open the **Debug Settings** section on the component to access debug options.\
Displays the component's unique ID, registration state, and grouped part count.

Use **Debug Draw Flags** to control where gizmos render: Scene View, Game View, or both.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://mindcodeinteractive.gitbook.io/easy-build-system/reference/building-group.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
