Lock a Prefab

The main feature of BlackBox is to enable locking Prefabs, hiding their complexity to the user.

The UI of the BlackBox of a locked Prefab

A locked Prefab has two main characteristics:

  • Only the root GameObject is displayed in the Hierarchy window, no children.

  • No components visible in the Inspector other than Transform and BlackBox.

Thus, it becomes impossible to create overrides on the invisible objects and components. It is only possible to create them on the Transform and on the GameObject's base properties (static flags, layers, tags, ...).

How to lock a Prefab

Locking a Prefab is done by just adding the BlackBox component to it.

You can either:

  • Open the Prefab in Prefab mode, and add the BlackBox component.

  • Alternatively, you can add the BlackBox component to a GameObject in the scene and then turn it into a Prefab by dragging it into the Project view.

Both cases lead to the same result: the Prefab is now locked for edits.

A Prefab made of several objects, locked, appears as one GameObject in the scene

Entering Prefab mode reveals the hidden aspects:

The same locked Prefab, now seen "from the inside"

In Prefab mode, all children and root components become visible again, and editable.

Tip: BlackBox has full support for Prefab nesting and Variants. Try nesting locked Prefabs, and see what happens!

Temporarily unlocking a Prefab

While in Prefab mode, one can unlock the Prefab by just unchecking the Locked property in the Inspector. When doing so, the Prefab now shows again all its children and components when seen outside of Prefab mode, but the BlackBox component is still there so it can be used at a later stage.

Last updated