Beruflich Dokumente
Kultur Dokumente
Who Am I?
Developer at Unity Used to make games!
Bioshock 1 / 2
Responsible for:
Editor features Graphics features
Topics
Topics
Overview
Overview
Assembly reload
Pull all data out of managed (mono) land Create internal representation of the data on C++ side Destroy all memory / information in managed land Reload assemblies Reserialize the data from c++ into managed
Serializing Classes
A simple class will not automatically serialize! Unity does not know if the class is meant to serialize or not!
We can x this!
Serializing Classes
Serializing Classes
Serializing Structs
Serializing ScriptableObject
Serializing ScriptableObject
Serializing ScriptableObject
Initialization order
Instance created Fields deserialized into object If they exist on the c++ side ;) OnEnable() Called
Serializing ScriptableObject
Hideags
Control visibility
Important if you are NOT saving the asset or holding a reference to it i.e editor only data structure referenced by a window
HideAndDontSave
No asset / scene root - tells unity to consider this a root object Will not get cleaned up on scene load (play mode) Destroy using Destroy ()
Works as expected
No object sheering Serialized and deserialized properly
ScriptableObject Array!
Serializes as references... Will serialize as expected Only need to set hideags on the most root object
Asset Creation
Custom Asset UI
Property Fields
Property Fields
How?
[CustomPropertyDrawer (typeof (MyType))] Extend PropertyDrawer Need a custom height? Override GetPropertyHeight () Do your custom drawing OnGUI ()
Using Assets
Create a reference to the type
Can be anywhere: EditorWindow MonoBehaviour
Connect it to an asset
Via code or the inspector
Using Sub-Assets
ScriptableObjects
Save each manually... they wont serialize to le all the way down
How?
Add them as children of another asset (AddObjectToAsset) By default it will show all assets as sub assets Set HideFlags to HideFlags.HideInHierarchy Much nicer :)
Using Sub-Assets
Use SubAssets for complex data structures
Where many elements are ScriptableObjects Graphs Databases ect!