2. Disclaimer
The purpose of these slides is to give general overview how
to extend unity3d editor to unity3d dev team of company(frag
games).
I did not own the whole material of these slides most of the
stuff is taken from unity3d Documentation.
7. MainGUIComponents.
Unity provides three classes GUI, EditorGUI & EditorGUILayout
which contains function to draw GUI components.
GUI class can be used for both in game & editor code.
EditorGUILayout is auto-layout version of EditorGUI
11. PropertyDrawers
Property Drawers can be used
to customize the look of
certains controls in
Inspector.
There are two types of
property drawers
Built in
Custom
builtin-Example
18. CustomInspector
1: pass class name
2: Extends with Editor
3: target contains under
inspection class data
4: here do draw stuff
5: utilities
If you want to study the
source code of this custom
inspector see this link
25. Description
Gizmos are used to give visual debugging or setup aid in
scene view.
Use OnDrawGizmos or OnDrawGizmosSelected in your class to
draw them.
First one get called in every frame second get called only
when object is selected to whom this script is attached.
30. ScriptableObjects
Scriptableobject is a class that allows you to store large
quantities of shared data independent from script instance.
they don’t need to be attached to game objects.
Read Only at run-time
Usecase:
Reduce memory usage by avoiding copies of values
Define pluggable data sets.
33. Serializationinunity[behindthescene]
{content of this section is taken from blog post written by
unity Dev who wrote unity serialization system}
Serialization of “things” is at very core of Unity.Many of
unity's features build on top of serialization system.
The serialization is written in C++.
35. Continued...
Storing Data (Inspector Window)
Inspector window doesn't talk to C# api for properties &
their values
It asks the object to serialize itself and then displays
serialized data.
36. Continued...
Prefabs
Internally, prefab is serialized data stream of game
object(s) & components
A prefab instance is a list of modifications that should be
made on the serialized data for this instance.
The concept of prefab only exist in editor, instantiated
gameobjects have no idea they were prefabs in editor.
37. Continued...
Instantiation
When you call Instantiate() on a prefab or on existing
gameobject
Object get serialized, new object created & and deserialize
the data on new object
if object contains reference to external objects reference
is kept as is, if it has reference to its children than
reference is patched to new copy
38. Continued...
Save/Load [Scene]
Unity saves it scenes as yaml file, you can check that by
opening scene with text editor, but you have to set unity
to “force text serialization”
Loading of scenes & assets uses serialization system
39. Lastfewwordsonserialization
{don’t confuse this serialization with some
3rd party library}
How many
allocations are made
when deserializing a
monobehaviour that
uses this script.
No support
for null for
custom class
No support
for
polymorphism
Correct answer is 729 with 7 level depth
limit
40. WhentowritecustomEditor
When we learn something
new we tend to overuse
It.
Don't hesitate just write
Custom editor with
Experience you get
“Right Use”
Right Use
overuse
under-use