Game Development Reference
In-Depth Information
Next, we've created the function, which will get the waypoints array from the children
of this _waypointsContainer object. Then, we write the following line to find the
waypoint object using the following index:
seo_object.FindProperty (string.Format (s_arrayData, index))
Note
FindProperty allows us to pass the name of the object and return the Serial-
izedProperty object. In this case, we need to access the array, so we use the
string.Format() function and pass the string and index to get the result string such
as waypoints.Array.data[index] .
For more information on string.Format() , visit http://msdn.microsoft.com/en-us/
library/system.string.format(v=vs.110).aspx .
At the SetWaypoint() function, we've updated the name of waypoint by index, set it
to the waypoints array, and used Undo.RecordObject() to record the object in-
formation for the undo command. In the RemoveWaypointAtIndex() function, we
basically removed the waypoint by index, saved the information of the object for undo,
and destroyed the object by using Undo.DestroyObjectImmediate() .
Then in the AddWayPoint() function, we just increase the size of the array and add the
new waypoint object.
Next, we created the OnInspectorGUI() function and applied all the properties by us-
ing the EditorGUILayout object to access each type of the object. This object is sim-
ilar to the GUILayout object, and it allows us to get and set the property.
Note
For more details, visit the following links:
http://docs.unity3d.com/Documentation/ScriptReference/Edit-
or.OnInspectorGUI.html
http://docs.unity3d.com/412/Documentation/ScriptReference/EditorGUILay-
out.html
Search WWH ::




Custom Search