# Prefab and Object Manager

## Overview

The **Prefab And Object Manager** is a component you can attach to any object in your scene, which makes it very easy to create groups of `Game Objects` and `Prefabs` -- individually or mixed together -- which you can turn on in your project with a single line of code.

For static game objects, such as furniture in a room, or props on a table, this script is all you need.

For characters or other objects using the wardrobe and/or blend shapes, you may want to also add the [**Wardrobe Prefab Manager**](/magic-pig-games/equipment-systems/wardrobe-prefab-manager.md) (required for rigging objects added to the scene), and the [**Blend Shapes Manager**](/magic-pig-games/equipment-systems/blend-shapes-manager.md) (required for working with mesh morphing).

{% embed url="<https://youtu.be/hYZ3FpXjzn8>" %}

{% hint style="danger" %}
Are you already using Infinity PBR content prior to this update (\~March 2022)? If so, there's a few things to keep in mind when updating.

1. This script is the new version of `PrefabChildManager.cs`, and replaces it. I've renamed it to better identify what it actually does. Any references in your custom code to the old script may need to be updated to the new one.
2. In the class `PrefabGroup`, the field `prefabObjects` has been renamed to `groupObjects`. If your scripts reference `prefabObjects`, errors will be shown in the console. You'll need to update your scripts to update this reference.
3. Any wardrobe that will be equipped needs to have a `EquipmentObject` component on it. This will self populate once you add the component. *If your adding this to object that are in a prefab (via the prefab view editor), **turn off "Auto Save"** -- it looks like there is a bug where the scripts will self-populate, but that data will NOT be saved if Auto Save is turned on.*
   {% endhint %}

## Setup

Select the parent of the object -- often the "place" where objects will be related to, or for wardrobe, the character. In the inspector, click "Add Component", and search for Prefab And Object Manager. Add it!

## Inspector

There are three tabs in the Inspector.

![](/files/rJP78SyftyF7ohQ3GVHs)

{% tabs %}
{% tab title="Prefab Groups" %}
![](/files/EyCrBt6o2UlLxukKHObO)

This is where you create and manage your Prefab Groups. Type in the "Type", and the sort order will update. Name the "Group Name" something unique, as this is used with scripting.

At edit time, use the "Activate" and "Deactivate" buttons to see the results.

See full details on the [**Prefab Groups**](/magic-pig-games/equipment-systems/prefab-and-object-manager/prefab-groups.md) page.
{% endtab %}

{% tab title="Group Types" %}
![](/files/XBJvexuKjussx7ldiZXO)

Once you have defined Group Types (in the Prefab Groups tab), they will display here, where you can change the type name for all of the Prefab Groups at once.
{% endtab %}

{% tab title="Setup & Options" %}
![](/files/aITd0lxhuq3n1BWs6DjP)

Toggle **"Show Help Boxes"** on to reveal Inspector boxes with additional context, beyond the tool tips.

**"Show Full Inspector"** will show, at the bottom, the full Inspector for the script. This may be useful for debugging, but data should not be manipulated via the full inspector.

With **"Instantiate Prefabs when Added to Group"** on, prefabs that are added to a Prefab Group will be instantiated in the scene, helping you visualize what the full group looks like.

**"Only one group active per type"** will ensure that, for any named Group Type, there will only be one Prefab Group active at a time. This means that if you call `Activate(groupName`), any active group of that type will automatically deactivate first. Essentially this allows you to switch groups with a single line of code.

**"Unpack Prefabs when Instantiated"** is on by defualt, and is suggested to remain on. If true, prefabs will be unpacked. If they are not unpacked, certain features, like deleting objects, may throw errors.
{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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:

```
GET https://infinitypbr.gitbook.io/magic-pig-games/equipment-systems/prefab-and-object-manager.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
