Comment on page
Prefab and Object Manager
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
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.
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
prefabObjectshas 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
EquipmentObjectcomponent 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.
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!
There are three tabs in the Inspector.
Setup & Options
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.
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.
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.