Locking Prefabs

The main feature of BlackBox is to lock Prefabs, to hide their complexity from 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 the Transform and BlackBox itself.

This prevents creating overrides on the invisible objects and components by mistake. It is only possible to override the Transform's and 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.

Unlocking a Prefab

While in Prefab mode, you can unlock the Prefab by just unchecking the Locked property in the Inspector. 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