> For the complete documentation index, see [llms.txt](https://flora.magneticarcade.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://flora.magneticarcade.com/scripts/instance-container.md).

# Instance Container

The **Instance Container** component is designed to manage large groups of instanced meshes—such as foliage, debris, or props—**without requiring individual GameObjects**.

It serializes instance transform data, integrates with the central [FloraSystem](/scripts/system.md), and exposes a simple API for adding, updating, querying, and removing instances at runtime or in the editor.

See also: [Conversion](/getting-started/conversion.md)

> For workflows without Unity `Terrain`, this is the primary Flora path for managing large groups of instances without individual GameObjects. See [Container Mesh Sample](/samples/container-samples.md#container-mesh-sample) and [Container Prefab Sample](/samples/container-samples.md#container-prefab-sample).\
> For Unity `Terrain` trees/details, use [Terrain Provider](/scripts/terrain-provider.md).

<figure><img src="/files/HT9AU7koVOA7YZiyXllU" alt="Instance Container UI"><figcaption></figcaption></figure>

***

### Properties

#### <mark style="color:yellow;">Prefab</mark>

The prefab rendered by all instances in this container.\
Changing this will **rebuild** all instances.

#### <mark style="color:yellow;">InstanceHandles</mark>

An array of runtime **instance handles**, used internally by Flora to track each instance.

#### <mark style="color:yellow;">LocalTransforms</mark>

An array of **container-space transforms** (position, rotation, scale) for each instance.

***

### Example

Basic runtime usage for spawning instances into a container:

```csharp
public class FoliageSpawner : MonoBehaviour
{
    public FloraInstanceContainer container;
    public GameObject treePrefab;

    void Start()
    {
        container.Prefab = treePrefab;

        // Spawn 100 instances in a 10x10 grid
        for (int x = 0; x < 10; x++)
        for (int z = 0; z < 10; z++)
        {
            Vector3 pos = new Vector3(x * 2f, 0, z * 2f);
            container.AddInstance(pos, Quaternion.identity, Vector3.one, Space.World);
        }
    }
}
```
