public void Apply () {
if (AstarPath.active == null) {
Debug.LogError ("There is no AstarPath object in the scene");
return;
}
GraphUpdateObject guo;
if (points == null || points.Length == 0) {
Bounds b;
if (collider != null) b = collider.bounds;
else if (renderer != null) b = renderer.bounds;
else {
Debug.LogWarning ("Cannot apply GraphUpdateScene, no points defined and no renderer or collider attached");
return;
}
if (b.size.y < minBoundsHeight) b.size = new Vector3(b.size.x,minBoundsHeight,b.size.z);
guo = new GraphUpdateObject (b);
} else {
Pathfinding.GraphUpdateShape shape = new Pathfinding.GraphUpdateShape ();
shape.convex = convex;
Vector3[] worldPoints = points;
if (!useWorldSpace) {
worldPoints = new Vector3[points.Length];
Matrix4x4 matrix = transform.localToWorldMatrix;
for (int i=0;i<worldPoints.Length;i++) worldPoints[i] = matrix.MultiplyPoint3x4 (points[i]);
}
shape.points = worldPoints;
Bounds b = shape.GetBounds ();
if (b.size.y < minBoundsHeight) b.size = new Vector3(b.size.x,minBoundsHeight,b.size.z);
guo = new GraphUpdateObject (b);
guo.shape = shape;
}
firstApplied = true;
guo.modifyWalkability = modifyWalkability;
guo.setWalkability = setWalkability;
guo.addPenalty = penaltyDelta;
guo.updatePhysics = updatePhysics;
guo.updateErosion = updateErosion;
guo.resetPenaltyOnPhysics = resetPenaltyOnPhysics;
#if ConfigureTagsAsMultiple
guo.tags = tags;
#else
guo.modifyTag = modifyTag;
guo.setTag = setTag;
#endif
AstarPath.active.UpdateGraphs (guo);
}