GenerativeArt–MadewithUnity
1
Technical Deep
Dive into the New
Prefab System
Steen Lund
Tech Lead, Unity Technologies
@steenlund
Agenda
2
● Prefab Assets, Instances and Content
● Prefab Importing
● Prefab Mode
● Unpacking
● Scripting and Tooling
Takeaway
3
● Knowledge of how the backend works
● Changes to Unity’s handling of Prefabs assets
● Knowledge of Prefab tooling in the Editor
Project Goals
4
5
Nested Prefabs
TableScene
Table
LegLeg
Table
VaseVase
Vase
Vase
6
Prefab Variants
CatScene
Cat
(instance
of Animal)
Cat Animal
Animal
Editing in isolation
7
Give some, take some
8
• No more disconnected Prefab instances
• No more editing directly in the Project Browser
Prefab Assets,
Instances and Content
9
10
GameObject
in scene
11
Make GameObject
into Prefab instance
12
Drag the GameObject
to Project Browser
13
What is a Prefab
14
Instance?
15
PrefabInstance
Handle
Instance
Leg
Table
More than you see with the
naked eye
16
corresponding object
Instance Asset
17
AssetInstance
Table
LegLeg
Table
18
Prefabs in Scene files
Main Camera
Directional Light
Scene File
PrefabInstance
Handle
Loaded Scene
PrefabInstance
Handle
What is a Prefab Asset?
19
Prefab File
Table
Leg
20
Consider a Prefab Asset being a scene
Prefab File
Table
Leg
PrefabInstance
Handle
Prefab Importing
21
22
Prefab File in Assets Folder
Prefab Importer
Table
Leg
Prefab File in Library Folder
Prefab Asset Handle
Table
Leg
23
Prefab File in Assets Folder Prefab File in Library Folder
Prefab Importer
Table
Leg
PrefabInstance
Handle
Prefab Asset Handle
Table
Leg
Vase
PrefabInstance
Handle
24
Prefab Variant File in Assets Folder Prefab File in Library Folder
Prefab Importer
PrefabInstance
Handle
Prefab Asset Handle
Vase
PrefabInstance
Handle
Corresponding Objects
With Nesting
25
Corresponding Objects with Nesting
26
Table
LegLeg
Table
VaseVase Vase
TableScene Vase
Corresponding Objects with Variants
27
CatCat Animal
CatScene Animal
28
Dependency chain
Prefab Importer Prefab Importer
Inner Middle Outer
29
Build size implications
● No change for Scene, have always been baked out at build time
● Resources and AssetBundles are affected
AA A
B C
30
PrefabAsset
Handle
PrefabInstance
Handle
Asset in Library FolderPrefab Instance
Table
LegLeg
Table
VaseVase
PrefabInstance
Handle
Prefab Mode
31
32
Edit Prefab
in Prefab Mode
Prefab Mode
Editing Prefab Asset
content

not Prefab instance
GameObject icon
not Prefab icon
Saving

not applying
33
34
Prefab
Asset
Prefab
instance
Prefab contents
in Prefab Mode
automatic
update
apply
open from instance
open from asset
save
Unpacking
35
36
Prefabs can no longer be disconnected
37
38
Make Prefab instance
into GameObject
Unpack Prefab Contents
(one layer)
39
Make Prefab instance
into GameObject
Unpack Prefab Contents
(one layer)
Prefab Variant
becomes its base
40
Scripting and Tooling
41
Editor Stages
42
• Main Stage
• Prefab Stage
• ….
Editor Stages
43
• [ExecuteInEditMode]
• Will leave Prefab Mode
• [ExecuteAlways]
Editor Stages: [ExecuteAlways]
44
void Update()
{
// Rotate only in playmode
// We don't want this in edit mode nor in prefab mode
// as it would update the prefab asset
if (Application.IsPlaying(this))
{
Transform t = GetComponent<Transform>();
t.Rotate(rotationSpeed * Time.deltaTime, 0, 0);
}
++updateCount;
Debug.Log(string.Format("Updates {0}", updateCount));
}
Case:
45
I want to dynamically create an editing
environment for my prefab
46
I want to dynamically create an editing
environment for my prefab
using UnityEditor.Experimental.SceneManagement;
[InitializeOnLoad]
class CustomPrefabEnvironment
{
static CustomPrefabEnvironment()
{
PrefabStage.prefabStageOpened += OnPrefabStageOpened;
}
static void OnPrefabStageOpened(PrefabStage prefabStage)
{
…
Case:
47
Is my GameObject a Prefab (and what kind)?
Is my GameObject a Prefab (and what kind)?
48
PrefabInstanceStatus GetPrefabInstanceStatus(Object componentOrGameObject)
PrefabAssetType GetPrefabAssetType(Object componentOrGameObject)
bool IsAnyPrefabInstanceRoot(GameObject gameObject)
bool IsOutermostPrefabInstanceRoot(GameObject gameObject)
bool IsPartOfAnyPrefab([Object componentOrGameObject)
bool IsPartOfImmutablePrefab(Object componentOrGameObject)
bool IsPartOfPrefabThatCanBeAppliedTo(Object componentOrGameObject)
bool IsPartOfPrefabAsset(Object componentOrGameObject)
bool IsPartOfPrefabInstance(Object componentOrGameObject)
bool IsPartOfNonAssetPrefabInstance(Object componentOrGameObject)
bool IsPartOfRegularPrefab(Object componentOrGameObject)
bool IsPartOfModelPrefab(Object componentOrGameObject)
bool IsPartOfVariantPrefab(Object componentOrGameObject)
bool IsDisconnectedFromPrefabAsset(Object componentOrGameObject)
bool IsPrefabAssetMissing(Object instanceComponentOrGameObject)
Is my GameObject a Prefab (and what kind)?
49
if (PrefabUtility.IsPartOfPrefabInstance(go))
{
var type = PrefabUtility.GetPrefabAssetType(go);
Debug.Log(string.Format("GameObject is part of a Prefab Instance of type {0}" ,type));
}
else
{
Debug.Log("Selected GameObject is not part of a Prefab Instance");
}
Case:
50
How do I know if 2 GameObjects are part of the
same Prefab Instance?
51
How do I know if 2 GameObjects are part of the same Prefab Instance?
var firstHandle = PrefabUtility.GetPrefabInstanceHandle(Selection.gameObjects[0]);
var secondHandle = PrefabUtility.GetPrefabInstanceHandle(Selection.gameObjects[1]);
if (firstHandle == secondHandle)
Debug.Log("GameObject belongs to same instance");
else
Debug.Log("GameObject are not from the same instance");
Case:
52
I want to create a Prefab from script
I want to create a Prefab from script
53
var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
// If you simply want the cube to be written as an asset but not turn into a prefab instance
// use this method
PrefabUtility.SaveAsPrefabAsset(cube, path);
// This method will create a Prefab asset and make the GameObject an instance of the
// new prefab asset
PrefabUtility.SaveAsPrefabAssetAndConnect(cube, path, InteractionMode.AutomatedAction);
Case:
54
I want to create a Prefab Variant from script
I want to create a Prefab Variant from script
55
if (isAsset)
{
path = AssetDatabase.GetAssetPath(go);
go = (GameObject)PrefabUtility.InstantiatePrefab(go);
}
else if (isInstance)
{
go = PrefabUtility.GetOutermostPrefabInstanceRoot(go);
path = AssetDatabase.GetAssetPath(PrefabUtility.GetCorrespondingObjectFromSource(go));
}
var prefabName = System.IO.Path.GetFileNameWithoutExtension(path);
path = System.IO.Path.GetDirectoryName(path);
PrefabUtility.SaveAsPrefabAsset(go, path + "/" + prefabName + " Variant.prefab");
Case:
56
I want to nest Prefabs from script
57
I want to nest Prefabs from script
var instanceA = (GameObject)PrefabUtility.InstantiatePrefab(goA);
var instanceB = (GameObject)PrefabUtility.InstantiatePrefab(goB);
instanceB.GetComponent<Transform>().parent = instanceA.GetComponent<Transform>();
PrefabUtility.ApplyPrefabInstance(instanceA, InteractionMode.AutomatedAction);
58
I want to nest Prefabs from script
var instanceB = (GameObject)PrefabUtility.InstantiatePrefab(goB);
var root = PrefabUtility.LoadPrefabContents(path);
instanceB.GetComponent<Transform>().parent = root.GetComponent<Transform>();
PrefabUtility.SaveAsPrefabAsset(root, path);
PrefabUtility.UnloadPrefabContents(root);
Case:
59
I want to change a flag on multiple Prefabs assets
60
I want to change a flag on multiple Prefabs assets
// Load the content of the Prefab asset so we can modify it
var assetRoot = PrefabUtility.LoadPrefabContents(path);
GameObjectUtility.SetStaticEditorFlags(assetRoot, StaticEditorFlags.LightmapStatic);
// Write the updated GameObject to the Prefab asset
PrefabUtility.SaveAsPrefabAsset(assetRoot, path);
// Clean up is important or we will leak scenes and
// eventually run out of temporary scenes.
PrefabUtility.UnloadPrefabContents(assetRoot);
Case:
61
I want to add assets to my prefab file
AssetDatebase.AddObjectToAsset(newObject, asset);
Case:
62
Advanced: I modified a Library folder object,
now I want to update the source asset
63
Advanced: I modified a Library folder object,
now I want to update the source asset
string path = "Assets/Prefabs/A.prefab";
var goA = (GameObject)AssetDatabase.LoadMainAssetAtPath(path);
GameObjectUtility.SetStaticEditorFlags(goA, ~GameObjectUtility.GetStaticEditorFlags(goA));
PrefabUtility.SavePrefabAsset(goA);
64
Example code:
https://github.com/Unity-Technologies/UniteLA2018Examples
Scripting reference
https://docs.unity3d.com/2018.3/Documentation/ScriptReference/PrefabUtility.html
Prefabs landing page: https://unity3d.com/prefabs
Nikoline Høgh:
Oct. 24th 10 AM
Prefab Workflow Improvements – An Introduction
Location: Diamond 5
65
Questions?

More Related Content

PPTX
Building a turn-based game prototype using ECS - Unite Copenhagen 2019
PPTX
언리얼4 플레이어 컨트롤러의 이해.
PPTX
Parallel Futures of a Game Engine
PDF
레퍼런스만 알면 언리얼 엔진이 제대로 보인다
PDF
이무림, Enum의 Boxing을 어찌할꼬? 편리하고 성능좋게 Enum 사용하기, NDC2019
PDF
Unreal Engine 5 早期アクセスの注目機能総おさらい Part 1
PDF
UE4 MultiPlayer Online Deep Dive 実践編2 (ソレイユ株式会社様ご講演) #UE4DD
PPTX
GTMF 2016:Perforce HelixによるGit環境の改善と拡張 株式会社東陽テクニカ(Perforce Helix)
Building a turn-based game prototype using ECS - Unite Copenhagen 2019
언리얼4 플레이어 컨트롤러의 이해.
Parallel Futures of a Game Engine
레퍼런스만 알면 언리얼 엔진이 제대로 보인다
이무림, Enum의 Boxing을 어찌할꼬? 편리하고 성능좋게 Enum 사용하기, NDC2019
Unreal Engine 5 早期アクセスの注目機能総おさらい Part 1
UE4 MultiPlayer Online Deep Dive 実践編2 (ソレイユ株式会社様ご講演) #UE4DD
GTMF 2016:Perforce HelixによるGit環境の改善と拡張 株式会社東陽テクニカ(Perforce Helix)

What's hot (20)

PPTX
Killzone Shadow Fall: Threading the Entity Update on PS4
PDF
『ガールズ&パンツァー 最終章』第3話 アニメとゲームエンジンの融合(ジャングル完結編) UNREAL FEST EXTREME 2021 SUMMER
PDF
Optimizing Large Scenes in Unity
PPTX
System centerを中心とした統合管理-オンプレミスからクラウドまで
PPTX
DirectX 11 Rendering in Battlefield 3
PDF
アニメーションとスキニングをBurstで独自実装する.pdf
PPTX
[0903 구경원] recast 네비메쉬
PPTX
Unity asset workflows for Film and Animation pipelines - Unite Copenhagen 2019
PPT
슈팅 게임에서 레벨 디자인 하기
PPTX
なぜなにリアルタイムレンダリング
PPTX
【CEDEC2018】Scriptable Render Pipelineを使ってみよう
PDF
【Unite 2018 Tokyo】60fpsのその先へ!スマホの物量限界に挑んだSTG「アカとブルー」の開発設計
PPTX
Scene Graphs & Component Based Game Engines
PPTX
MVPパターンによる設計アプローチ「あなたのアプリ報連相できてますか」
PDF
多機能ボイチャを簡単に導入する方法
PDF
Unity道場08 Unityとアセットツールで学ぶ 「絵づくり」の基礎 ライティング 虎の巻
PDF
[NDC17] Unreal.js - 자바스크립트로 쉽고 빠른 UE4 개발하기
PDF
08_게임 물리 프로그래밍 가이드
PDF
Unity Roadmap 2020: Core Engine & Creator Tools
PDF
Screen Space Decals in Warhammer 40,000: Space Marine
Killzone Shadow Fall: Threading the Entity Update on PS4
『ガールズ&パンツァー 最終章』第3話 アニメとゲームエンジンの融合(ジャングル完結編) UNREAL FEST EXTREME 2021 SUMMER
Optimizing Large Scenes in Unity
System centerを中心とした統合管理-オンプレミスからクラウドまで
DirectX 11 Rendering in Battlefield 3
アニメーションとスキニングをBurstで独自実装する.pdf
[0903 구경원] recast 네비메쉬
Unity asset workflows for Film and Animation pipelines - Unite Copenhagen 2019
슈팅 게임에서 레벨 디자인 하기
なぜなにリアルタイムレンダリング
【CEDEC2018】Scriptable Render Pipelineを使ってみよう
【Unite 2018 Tokyo】60fpsのその先へ!スマホの物量限界に挑んだSTG「アカとブルー」の開発設計
Scene Graphs & Component Based Game Engines
MVPパターンによる設計アプローチ「あなたのアプリ報連相できてますか」
多機能ボイチャを簡単に導入する方法
Unity道場08 Unityとアセットツールで学ぶ 「絵づくり」の基礎 ライティング 虎の巻
[NDC17] Unreal.js - 자바스크립트로 쉽고 빠른 UE4 개발하기
08_게임 물리 프로그래밍 가이드
Unity Roadmap 2020: Core Engine & Creator Tools
Screen Space Decals in Warhammer 40,000: Space Marine
Ad

Similar to Technical Deep Dive into the New Prefab System (20)

PPTX
Technical Deep Dive into the New Prefab System
PDF
Refresh what you know about AssetDatabase.Refresh()- Unite Copenhagen 2019
PPTX
Speed up your asset imports for big projects - Unite Copenhagen 2019
PPTX
Unity3 d devfest-2014
PPTX
Cross platform game development
PDF
Introduction to Unity by Purdue university
PDF
School For Games 2015 - Unity Engine Basics
PPTX
Ottawa unity user_group_feb13_2015
PDF
Developing VR Experiences with Unity
PDF
Mobile AR Lecture6 - Introduction to Unity 3D
PDF
IRJET- Technical Graphic Showcase
PPTX
Creating great Unity games for Windows 10 - Part 1
PDF
Save System in Garden of the Sea: How to save the state of an open-ended gard...
PPTX
Game development -session on unity 3d
PPTX
Introduction to Unity
PDF
[UniteKorea2013] Art tips and tricks
PDF
Mcqs unity
PPTX
Game Project / Working with Unity
PPTX
PDF
Laser Defender Game in Unity3D
Technical Deep Dive into the New Prefab System
Refresh what you know about AssetDatabase.Refresh()- Unite Copenhagen 2019
Speed up your asset imports for big projects - Unite Copenhagen 2019
Unity3 d devfest-2014
Cross platform game development
Introduction to Unity by Purdue university
School For Games 2015 - Unity Engine Basics
Ottawa unity user_group_feb13_2015
Developing VR Experiences with Unity
Mobile AR Lecture6 - Introduction to Unity 3D
IRJET- Technical Graphic Showcase
Creating great Unity games for Windows 10 - Part 1
Save System in Garden of the Sea: How to save the state of an open-ended gard...
Game development -session on unity 3d
Introduction to Unity
[UniteKorea2013] Art tips and tricks
Mcqs unity
Game Project / Working with Unity
Laser Defender Game in Unity3D
Ad

More from Unity Technologies (20)

PDF
Build Immersive Worlds in Virtual Reality
PDF
Augmenting reality: Bring digital objects into the real world
PDF
Let’s get real: An introduction to AR, VR, MR, XR and more
PDF
Using synthetic data for computer vision model training
PDF
The Tipping Point: How Virtual Experiences Are Transforming Global Industries
PDF
Unity Roadmap 2020: Live games
PDF
How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...
PPTX
Unity XR platform has a new architecture – Unite Copenhagen 2019
PDF
Turn Revit Models into real-time 3D experiences
PDF
How Daimler uses mobile mixed realities for training and sales - Unite Copenh...
PDF
How Volvo embraced real-time 3D and shook up the auto industry- Unite Copenha...
PDF
QA your code: The new Unity Test Framework – Unite Copenhagen 2019
PDF
Engineering.com webinar: Real-time 3D and digital twins: The power of a virtu...
PDF
Supplying scalable VR training applications with Innoactive - Unite Copenhage...
PDF
XR and real-time 3D in automotive digital marketing strategies | Visionaries ...
PDF
Real-time CG animation in Unity: unpacking the Sherman project - Unite Copenh...
PDF
Creating next-gen VR and MR experiences using Varjo VR-1 and XR-1 - Unite Cop...
PDF
What's ahead for film and animation with Unity 2020 - Unite Copenhagen 2019
PDF
How to Improve Visual Rendering Quality in VR - Unite Copenhagen 2019
PDF
Digital twins: the power of a virtual visual copy - Unite Copenhagen 2019
Build Immersive Worlds in Virtual Reality
Augmenting reality: Bring digital objects into the real world
Let’s get real: An introduction to AR, VR, MR, XR and more
Using synthetic data for computer vision model training
The Tipping Point: How Virtual Experiences Are Transforming Global Industries
Unity Roadmap 2020: Live games
How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...
Unity XR platform has a new architecture – Unite Copenhagen 2019
Turn Revit Models into real-time 3D experiences
How Daimler uses mobile mixed realities for training and sales - Unite Copenh...
How Volvo embraced real-time 3D and shook up the auto industry- Unite Copenha...
QA your code: The new Unity Test Framework – Unite Copenhagen 2019
Engineering.com webinar: Real-time 3D and digital twins: The power of a virtu...
Supplying scalable VR training applications with Innoactive - Unite Copenhage...
XR and real-time 3D in automotive digital marketing strategies | Visionaries ...
Real-time CG animation in Unity: unpacking the Sherman project - Unite Copenh...
Creating next-gen VR and MR experiences using Varjo VR-1 and XR-1 - Unite Cop...
What's ahead for film and animation with Unity 2020 - Unite Copenhagen 2019
How to Improve Visual Rendering Quality in VR - Unite Copenhagen 2019
Digital twins: the power of a virtual visual copy - Unite Copenhagen 2019

Recently uploaded (20)

PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PDF
Cost to Outsource Software Development in 2025
PDF
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
PPTX
assetexplorer- product-overview - presentation
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PDF
Time Tracking Features That Teams and Organizations Actually Need
PDF
Wondershare Recoverit Full Crack New Version (Latest 2025)
PDF
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
PPTX
Patient Appointment Booking in Odoo with online payment
PPTX
Introduction to Windows Operating System
PDF
The Dynamic Duo Transforming Financial Accounting Systems Through Modern Expe...
PPTX
Tech Workshop Escape Room Tech Workshop
PDF
Salesforce Agentforce AI Implementation.pdf
PPTX
Cybersecurity: Protecting the Digital World
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PDF
MCP Security Tutorial - Beginner to Advanced
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
DOCX
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
Oracle Fusion HCM Cloud Demo for Beginners
Computer Software and OS of computer science of grade 11.pptx
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
Cost to Outsource Software Development in 2025
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
assetexplorer- product-overview - presentation
Advanced SystemCare Ultimate Crack + Portable (2025)
Time Tracking Features That Teams and Organizations Actually Need
Wondershare Recoverit Full Crack New Version (Latest 2025)
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
Patient Appointment Booking in Odoo with online payment
Introduction to Windows Operating System
The Dynamic Duo Transforming Financial Accounting Systems Through Modern Expe...
Tech Workshop Escape Room Tech Workshop
Salesforce Agentforce AI Implementation.pdf
Cybersecurity: Protecting the Digital World
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
MCP Security Tutorial - Beginner to Advanced
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx

Technical Deep Dive into the New Prefab System