SlideShare a Scribd company logo
GenerativeArt–MadewithUnity
Technical
Deep Dive
into the New
Prefabs System
1
2
Rune Skovbo JohansenSteen Lund
Agenda
3
● Prefab Assets, Instances and Content
● Prefab Importing
● Prefab Mode
● Nesting and Overrides at Multiple Levels
● Unpacking & Simple Refactoring
Takeaway
4
● Knowledge of how the backend works
● Changes to Unity’s handling of Prefabs assets
● Understanding the implications of nesting and overrides
● Tricks for working with Variant inheritance
Prefab Assets,
Instances and Content
5
6
GameObject
in scene
7
Make GameObject
into Prefab instance
8
Create overrides
on Prefab instance
9
corresponding object
Instance Asset
10
AssetInstance
Table
LegLeg
Table
11
Prefab AssetScene
Apply to Prefab Asset
12
Prefab AssetScene
Apply to Prefab Asset
13
Nested Prefabs
TableScene
Table
LegLeg
Table
VaseVase
Vase
Vase
14
Prefab Variants
CatScene
Cat
(instance
of Animal)
Cat Animal
Animal
What is a Prefab
15
Instance?
16
PrefabInstance
Handle
Instance
Leg
Table
More than you see with the
naked eye
17
Prefabs in Scene files
Main Camera
Directional Light
Scene File
PrefabInstance
Handle
Loaded Scene
PrefabInstance
Handle
What is a Prefab Asset?
18
Prefab File
Table
Leg
19
Consider a Prefab Asset being a scene
Prefab File
Table
Leg
PrefabInstance
Handle
Prefab Importing
20
21
Prefab File in Assets Folder
Prefab Importer
Table
Leg
Prefab File in Library Folder
Prefab Asset Handle
Table
Leg
22
Prefab File in Assets Folder Prefab File in Library Folder
Prefab Importer
Table
Leg
PrefabInstance
Handle
Prefab Asset Handle
Table
Leg
Vase
PrefabInstance
Handle
23
Prefab Variant File in Assets Folder Prefab File in Library Folder
Prefab Importer
PrefabInstance
Handle
Prefab Asset Handle
Vase
PrefabInstance
Handle
24
Dependency chain
Prefab Importer Prefab Importer
Inner Middle Outer
25
Build size implications
● No change for Scene, have always been baked out at build time
● Resources and AssetBundles are affected
AA A
B C
26
PrefabAsset
Handle
PrefabInstance
Handle
Asset in Library FolderPrefab Instance
Table
LegLeg
Table
VaseVase
PrefabInstance
Handle
Prefab Mode
27
28
Edit Prefab
in Prefab Mode
Prefab Mode
Editing Prefab Asset
content
not Prefab instance
GameObject icon
not Prefab icon
Saving
not applying
29
30
Prefab
Asset
Prefab
instance
Prefab contents
in Prefab Mode
automatic
update
apply
open from instance
open from asset
save
Corresponding Objects
With Nesting
31
32
AssetInstance in Scene
Table
LegLeg
Table
VaseVase
Multiple Levels of Corresponding Objects
33
Instance AssetInstance of instance
Corresponding Objects with Nesting
34
Table
LegLeg
Table
VaseVase Vase
TableScene Vase
Corresponding Objects with Variants
35
CatCat Animal
CatScene Animal
Overrides at
Multiple Levels
36
37
A Prefab instance
can have overrides
38
A nested/base
Prefab instance
can also have
overrides
39
An instance of
the outer Prefab
can also have
overrides
40
Overrides can exist
at every level
except innermost
41
Apply to outer Prefab
42
43
Outer InnerScene
Apply as Override
in Prefab ‘Outer’
44
Outer InnerScene
Apply as Override
in Prefab ‘Outer’
Apply to inner Prefab
45
46
Outer InnerScene
Apply to Prefab ‘Inner’
47
Outer InnerScene
Apply to Prefab ‘Inner’
48
Outer InnerScene
Apply to Prefab ‘Inner’
49
Outer InnerScene
Apply to Prefab ‘Inner’
Apply to inner Prefab
when outer has
override
50
51
Scene Outer Inner
Apply to Prefab ‘Inner’
51
52
Scene Outer Inner
Apply to Prefab ‘Inner’
52
53
Scene Outer Inner
Apply to Prefab ‘Inner’
53
54
Scene Outer Inner
Apply to Prefab ‘Inner’
54
Unpacking
55
56
Prefabs can no longer be disconnected
57
58
Make Prefab instance
into GameObject
Unpack Prefab Contents
(one layer)
59
Make Prefab instance
into GameObject
Unpack Prefab Contents
(one layer)
Prefab Variant
becomes its base
60
Simple Refactoring
61
Make Existing Prefab into Variant
62
CatCat
How to make Cat Prefab a Variant of a new Animal Prefab?
CatScene
Make Existing Prefab into Variant
63
CatCat
Make into Prefab
called Animal
CatScene
Make Existing Prefab into Variant
64
CatCat Animal
Make into Prefab
called Animal ✓
CatScene Animal
Make Existing Prefab into Variant
65
CatCat Animal
Make into Prefab
called Animal ✓
Cat (Variant)Scene Animal
66
and now in reverse
Make Prefab Variant into Regular Prefab
67
CatCat Animal
How to make Cat Prefab no longer a Variant of Animal Prefab?
CatScene Animal
Make Prefab Variant into Regular Prefab
68
CatCat Animal
Unpack Prefab
CatScene Animal
Make Prefab Variant into Regular Prefab
69
CatCat Animal
Unpack Prefab ✓
CatScene Animal
70
Can you make a Prefab a Variant of an existing other Prefab?
No, that’s not simple…
71
inheritance chains
Insert New Prefab in Inheritance Chain
72
CatCat Animal
How to insert new Mammal Prefab between Cat and Animal?
CatScene Animal
Insert New Prefab in Inheritance Chain
73
CatCat Animal
Make into Prefab
called Mammal
CatScene Animal
Insert New Prefab in Inheritance Chain
74
CatCat Animal
Make into Prefab
called Mammal ✓
Mammal
CatScene Mammal Animal
75
and now in reverse
Remove Prefab from Inheritance Chain
76
CatCat AnimalMammal
How to make Cat Prefab inherit directly from Animal?
CatScene Mammal Animal
Remove Prefab from Inheritance Chain
77
CatCat AnimalMammal
Unpack Prefab
CatScene Mammal Animal
Remove Prefab from Inheritance Chain
78
CatCat AnimalMammal
Unpack Prefab ✓
CatScene Mammal Animal
Thank you
79
unity3d.com/prefabs

More Related Content

More from Unity Technologies

More from Unity Technologies (20)

How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...
How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...
How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...
 
Unity XR platform has a new architecture – Unite Copenhagen 2019
Unity XR platform has a new architecture – Unite Copenhagen 2019Unity XR platform has a new architecture – Unite Copenhagen 2019
Unity XR platform has a new architecture – Unite Copenhagen 2019
 
Turn Revit Models into real-time 3D experiences
Turn Revit Models into real-time 3D experiencesTurn Revit Models into real-time 3D experiences
Turn Revit Models into real-time 3D experiences
 
How Daimler uses mobile mixed realities for training and sales - Unite Copenh...
How Daimler uses mobile mixed realities for training and sales - Unite Copenh...How Daimler uses mobile mixed realities for training and sales - Unite Copenh...
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...
How Volvo embraced real-time 3D and shook up the auto industry- Unite Copenha...How Volvo embraced real-time 3D and shook up the auto industry- Unite Copenha...
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
QA your code: The new Unity Test Framework – Unite Copenhagen 2019QA your code: The new Unity Test Framework – Unite Copenhagen 2019
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...
Engineering.com webinar: Real-time 3D and digital twins: The power of a virtu...Engineering.com webinar: Real-time 3D and digital twins: The power of a virtu...
Engineering.com webinar: Real-time 3D and digital twins: The power of a virtu...
 
Supplying scalable VR training applications with Innoactive - Unite Copenhage...
Supplying scalable VR training applications with Innoactive - Unite Copenhage...Supplying scalable VR training applications with Innoactive - Unite Copenhage...
Supplying scalable VR training applications with Innoactive - Unite Copenhage...
 
XR and real-time 3D in automotive digital marketing strategies | Visionaries ...
XR and real-time 3D in automotive digital marketing strategies | Visionaries ...XR and real-time 3D in automotive digital marketing strategies | Visionaries ...
XR and real-time 3D in automotive digital marketing strategies | Visionaries ...
 
Real-time CG animation in Unity: unpacking the Sherman project - Unite Copenh...
Real-time CG animation in Unity: unpacking the Sherman project - Unite Copenh...Real-time CG animation in Unity: unpacking the Sherman project - Unite Copenh...
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...
Creating next-gen VR and MR experiences using Varjo VR-1 and XR-1 - Unite Cop...Creating next-gen VR and MR experiences using Varjo VR-1 and XR-1 - Unite Cop...
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
What's ahead for film and animation with Unity 2020 - Unite Copenhagen 2019What's ahead for film and animation with Unity 2020 - Unite Copenhagen 2019
What's ahead for film and animation with Unity 2020 - Unite Copenhagen 2019
 
How to Improve Visual Rendering Quality in VR - Unite Copenhagen 2019
How to Improve Visual Rendering Quality in VR - Unite Copenhagen 2019How to Improve Visual Rendering Quality in VR - 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
Digital twins: the power of a virtual visual copy - Unite Copenhagen 2019Digital twins: the power of a virtual visual copy - Unite Copenhagen 2019
Digital twins: the power of a virtual visual copy - Unite Copenhagen 2019
 
Virtual or real? AR Foundation best practices from Krikey - Unite Copenhagen ...
Virtual or real? AR Foundation best practices from Krikey - Unite Copenhagen ...Virtual or real? AR Foundation best practices from Krikey - Unite Copenhagen ...
Virtual or real? AR Foundation best practices from Krikey - Unite Copenhagen ...
 
Visualizing the engineering project lifecycle - Unite Copenhagen
Visualizing the engineering project lifecycle - Unite CopenhagenVisualizing the engineering project lifecycle - Unite Copenhagen
Visualizing the engineering project lifecycle - Unite Copenhagen
 
Driving AEC into a new age - Unite Copenhagen 2019
Driving AEC into a new age - Unite Copenhagen 2019Driving AEC into a new age - Unite Copenhagen 2019
Driving AEC into a new age - Unite Copenhagen 2019
 
A split screen-viable UI event system - Unite Copenhagen 2019
A split screen-viable UI event system - Unite Copenhagen 2019A split screen-viable UI event system - Unite Copenhagen 2019
A split screen-viable UI event system - Unite Copenhagen 2019
 
Mesh sculpting for realistic terrain features - Unite Copenhagen 2019
Mesh sculpting for realistic terrain features - Unite Copenhagen 2019 Mesh sculpting for realistic terrain features - Unite Copenhagen 2019
Mesh sculpting for realistic terrain features - Unite Copenhagen 2019
 
Bringing 2D characters to life with sprite rigging - Unite Copenhagen 2019
Bringing 2D characters to life with sprite rigging - Unite Copenhagen 2019Bringing 2D characters to life with sprite rigging - Unite Copenhagen 2019
Bringing 2D characters to life with sprite rigging - Unite Copenhagen 2019
 

Recently uploaded

Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 

Recently uploaded (20)

Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in Michelangelo
 
iGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by SkilrockiGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by Skilrock
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
GraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisGraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysis
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdf
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM Integration
 

Technical Deep Dive into the New Prefab System

Editor's Notes

  1. The PrefabInstance handle is a little more than a handle as it hold information about the location in the Transform hierarchy, List of overrides and deleted Components and a reference back to the Prefab asset it came from
  2. On the Left: Basically a scene file looks like this, there are two GameObject and a PrefabInstance object representing a prefab On the right: This expands into all GameObjects when loaded plus the PrefabInstance in memory mentioned on previously
  3. Basically just a collection of GameObject … Notice the similarity to a scene file
  4. Imagine for a moment if prefabs themselves could simply have a PrefabInstance object inside them that would expand into GameObjects when loaded But in order to do this we need to change the handling of Prefab in Unity a little
  5. Previous versions of Unity would read the Prefab file directly from the Assets folder, no importing was going on except some registration of the file
  6. The importer reads the prefab file, processes it and writes the hierarchy back to the Library folder The importer writes a little more then just the hierarchy A PrefabAssetHandle is also written to the Library folder All objects in the Library folder file points to the Prefab asset handle This is for internal use so we can track which Prefab Asset an object belongs to.
  7. The importer read the PrefabInstance handle, expands it and applies overrides, before writing the full hierarchy plus Prefab Instance handle to the Library folder
  8. Variant is similar to nesting but is simply at the root of the Prefab
  9. Performance implications, as a saving the inner prefab can spawn a series of imports which can feel slow depending on depth and size of prefab
  10. Does not change anything for scene as they have always been baked out at build time If Prefab A is nested inside, Prefab B, and Prefab C, A is in the build 3 times, on its own, in B and in C. Luckily GameObjects don’t take up much space, but it is still something to be aware of
  11. Now the fundamentals are in place lets examine some more advanced use cases