Game Development Reference
In-Depth Information
_wayPointsContainer = seo_object.targetObject as
WaypointsContainer;
}
}
We have used
SerializeObject
and
SerializeProperty
to access the
property from
WaypointsContainer
script and set all properties.
2. Next, we will add the functions to set, get, add, and remove waypoints. Let's add
the following code after the
OnEnable()
function:
// Unity JavaScript user:
function GetWaypointArray () : Waypoint[]
{
var waypoints : Waypoint[] =
_wayPointsContainer.GetComponentsInChildren.<Waypoint>();
return waypoints;
}
function GetWaypointAtIndex (index : int) : Waypoint
{
return seo_object.FindProperty (String.Format
(s_arrayData, index)).objectReferenceValue as
Waypoint;
}
function SetWaypoint (index : int, waypoint :
Waypoint)
{
if (waypoint != null) {
Undo.RecordObject(waypoint.gameObject,"Update"+index.ToString());
var nameIndex : String = (index < 9) ?
"0"+(index+1).ToString() : (index+1).ToString();
waypoint.name = OBJECT_NAME+nameIndex;
seo_object.FindProperty (String.Format
(s_arrayData, index)).objectReferenceValue = waypoint;
}
}
function RemoveWaypointAtIndex (index : int)
{