Class GraphUpdateScene Extends GraphModifier

Public

Helper class for easily updating graphs.

To use the GraphUpdateScene component, create a new empty GameObject and add the component to it, it can be found under Components–>Pathfinding–>GraphUpdateScene.

The region which the component will affect is defined by creating a polygon in the scene. If you make sure you have the Position tool enabled (top-left corner of the Unity window) you can shift+click in the scene view to add more points to the polygon. You can remove points using shift+alt+click. By clicking on the points you can bring up a positioning tool. You can also open the "points" array in the inspector to set each point's coordinates manually. In the inspector there are a number of variables. The first one is named "Convex", it sets if the convex hull of the points should be calculated or if the polygon should be used as-is. Using the convex hull is faster when applying the changes to the graph, but with a non-convex polygon you can specify more complicated areas.
The next two variables, called "Apply On Start" and "Apply On Scan" determine when to apply the changes. If the object is in the scene from the beginning, both can be left on, it doesn't matter since the graph is also scanned at start. However if you instantiate it later in the game, you can make it apply it's setting directly, or wait until the next scan (if any). If the graph is rescanned, all GraphUpdateScene components which have the Apply On Scan variable toggled will apply their settings again to the graph since rescanning clears all previous changes.
You can also make it apply it's changes using scripting. GetComponent<GraphUpdateScene>().Apply ();
The above code will make it apply its changes to the graph (assuming a GraphUpdateScene component is attached to the same GameObject).

Next there is "Modify Walkability" and "Set Walkability" (which appears when "Modify Walkability" is toggled). If Modify Walkability is set, then all nodes inside the area will either be set to walkable or unwalkable depending on the value of the "Set Walkability" variable.

Penalty can also be applied to the nodes. A higher penalty (aka weight) makes the nodes harder to traverse so it will try to avoid those areas.

The tagging variables can be read more about on this page: Working with tags.

Note

The Y (up) axis of the transform that this component is attached to should be in the same direction as the up direction of the graph. So if you for example have a grid in the XY plane then the transform should have the rotation (-90,0,0).

Public Methods

Apply ()

Updates graphs with a created GUO.

Public
DisableLegacyMode ()

Disables legacy mode if it is enabled.

Public
GetBounds ()

Calculates the bounds for this component.

Public
GetGraphUpdate ()

The GraphUpdateObject which would be applied by this component.

Public
InvertSettings ()

Inverts all invertable settings for this GUS.

Public
OnPostScan ()

Called right after all graphs have been scanned.

Public
RecalcConvex ()

Recalculate convex hull.

Public
Start ()

Do some stuff at start.

Public

Public Variables

applyOnScan

Apply this graph update object whenever a graph is rescanned.

Public
applyOnStart

Apply this graph update object on start.

Public
convex

Use the convex hull of the points instead of the original polygon.

Public
legacyMode

Emulates behavior from before version 4.0.

Public
minBoundsHeight

Minumum height of the bounds of the resulting Graph Update Object.

Public
modifyTag

Should the tags of the nodes be modified.

Public
modifyWalkability

If true, then all affected nodes will be made walkable or unwalkable according to setWalkability.

Public
penaltyDelta

Penalty to add to nodes.

Public
points

Points which define the region to update.

Public
resetPenaltyOnPhysics

Reset penalties to their initial values when updating grid graphs and updatePhysics is true.

Public
setTag

If modifyTag is enabled, set all nodes' tags to this value.

Public
setWalkability

Nodes will be made walkable or unwalkable according to this value if modifyWalkability is true.

Public
updateErosion

Update Erosion for GridGraphs.

Public
updatePhysics

Update node's walkability and connectivity using physics functions.

Public

Inherited Public Members

EventType

GraphModifier event type.

Public
FindAllModifiers ()
Public Static
OnGraphsPostUpdate ()

Called after graphs have been updated using GraphUpdateObjects.

Public
OnGraphsPreUpdate ()

Called before graphs are updated using GraphUpdateObjects.

Public
OnLatePostScan ()

Called at the end of the scanning procedure.

Public
OnPostCacheLoad ()

Called after cached graphs have been loaded.

Public
OnPreScan ()

Called right before graphs are going to be scanned.

Public
TriggerEvent (type)

Triggers an event for all active graph modifiers.

Public Static

Private/Protected Members

Awake ()
Protected
Awake ()
Protected
GetModifiersOfType<T> ()
Protected Static
OnDestroy ()
Protected
OnDisable ()

Removes this modifier from list of active modifiers.

Protected
OnDrawGizmos ()

Draws some gizmos.

Private
OnDrawGizmos (selected)

Draws some gizmos.

Private
OnDrawGizmosSelected ()

Draws some gizmos.

Private
OnEnable ()

Adds this modifier to list of active modifiers.

Protected
OnUpgradeSerializedData (version, unityThread)

Handle serialization backwards compatibility.

Protected
Reset ()

Handle serialization backwards compatibility.

Protected
UpgradeSerializedData (isUnityThread)
Protected
convexPoints

Private cached convex hull of the points.

Private
firstApplied

Has apply been called yet.

Private
legacyUseWorldSpace

Use world space for coordinates.

Private
serializedVersion
Private
setTagInvert

Private cached inversion of setTag.

Private
uniqueID

Unique persistent ID for this component, used for serialization.

Protected
usedIDs

Maps persistent IDs to the component that uses it.

Protected Static

Deprecated Members

LockToY ()

Lock all points to a specific Y value.

Public
ToggleUseWorldSpace ()

Switches between using world space and using local space.

Private