Game Development Reference
In-Depth Information
Objective complete - mini debriefing
First, we use
@CustomEditor(WaypointsContainer)
(in JavaScript) or
[Cus-
tomEditor(typeof(WaypointsContainer))]
(in C#) to tell Unity that this cus-
tom editor will be based on the
WaypointsContainer
script and we inherited the class
from the
Editor
class.
Next, we just added
SerializeObject
and
SerializeProperty
, which allows us
to access the property from the
WaypointsContainer
script.
Tip
We can also use
serializedObject
instead of the new
SerializedObject
(target)
too. The result is similar; however, in our case, we need to get the serialized
object from the target to make sure that when we delete the object in the
Hierarchy
view, it
won't return
null
.
Then, we use the
OnEnable()
function to initialize all the properties.
OnEnable()
is
the function that is called every time that the game object becomes enabled and active. This
function is opposite to
OnDisable()
, which will be called when the game object is dis-
abled and not active.
Note
We can use this to set the parameters or reset it when we enabled or disabled the game ob-
ject. To toggle the object that is disabled or enabled, we can use
gameOb-
ject.SetActive(true/false)
or check or uncheck the box in front of the game
object name in the
Inspector
view.
For more details, visit the following links: