Version: 2021.1
Editing a Prefab via its instances
Prefab Variants

Nested Prefabs

You can include Prefab instances inside other PrefabsAn asset type that allows you to store a GameObject complete with components and properties. The prefab acts as a template from which you can create new object instances in the scene. More info
See in Glossary
. This is called nesting Prefabs. Nested Prefabs retain their links to their own Prefab Assets, while also forming part of another Prefab Asset.

Adding a nested Prefab in Prefab Mode

In Prefab Mode, you can add and work with Prefab instances just like you would do in ScenesA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary
. You can drag a Prefab Asset from the Project windowA window that shows the contents of your Assets folder (Project tab) More info
See in Glossary
to the Hierarchy window or Scene viewAn interactive view into the world you are creating. You use the Scene View to select and position scenery, characters, cameras, lights, and all other types of Game Object. More info
See in Glossary
to create a Prefab instance from that Asset inside the Prefab you have open.

Note: The root GameObjectThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary
of the Prefab that is open in Prefab Mode is not shown with the blue cube Prefab icon, however any instances of other Prefabs are. You can also add overrides to these Prefab instances, just like with Prefab instances in scenes.

Left: GermOBlaster Prefab included (nested) in the “GermSlimeTarget” Prefab in Prefab Mode. Right: The “GermSlimeTarget” Prefab instance in the Scene with the “GermOBlaster” included.
Left: “GermOBlaster” Prefab included (nested) in the “GermSlimeTarget” Prefab in Prefab Mode. Right: The “GermSlimeTarget” Prefab instance in the Scene with the “GermOBlaster” included.

Nesting Prefabs via their instances

You can also add a Prefab instance as a child to another Prefab instance in the Scene without going into Prefab Mode, just like you can add any other GameObject. Such an added Prefab instance has a plus badge overlayed on the icon in the Hierarchy which indicates that it’s an override on that specific instance of the outer Prefab.

The added Prefab can be reverted or applied to the outer Prefab in the same way as other overrides (either via the Overrides drop-down window, or via the context menu on the GameObject in the Hierarchy), as described in Editing a Prefab via its instances. The Overrides drop-down button is only on the outer Prefab. Once applied, the Prefab no longer shows the plus badge, since it is no longer an override, but is nested in the outer Prefab Asset itself. It does however retain its blue cube icon because it is a Prefab instance in its own right, and retains its connection to its own Prefab Asset.

Left: An GermOBlaster Prefab added to an instance of the “GermSlimeTarget” Prefab as an override. Right: The “GermOBlaster” Prefab has been applied to “GermSlimeTarget” Prefab, and is now a nested Prefab in the “GermSlimeTarget” Prefab Asset.
Left: An “GermOBlaster” Prefab added to an instance of the “GermSlimeTarget” Prefab as an override. Right: The “GermOBlaster” Prefab has been applied to “GermSlimeTarget” Prefab, and is now a nested Prefab in the “GermSlimeTarget” Prefab Asset.

  • 2018–07–31 Page published

  • Nested Prefabs and Prefab Variants added in 2018.3

Editing a Prefab via its instances
Prefab Variants
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961