A* Pathfinding Project  4.3.8
The A* Pathfinding Project for Unity 3D
GraphModifier Class Reference

GraphModifier is used for modifying graphs or processing graph data based on events. More...

Detailed Description

GraphModifier is used for modifying graphs or processing graph data based on events.

This class is a simple container for a number of events.

{graph_events.png}

Warning
Some events will be called both in play mode and in editor mode (at least the scan events). So make sure your code handles both cases well. You may choose to ignore editor events.
See also
Application.IsPlaying
Warning
Events may be received before Awake and OnEnable has been called on the component. This is because graphs are typically scanned during Awake on the AstarPath component, which may happen before Awake on the graph modifier itself.

Public Types

enum  EventType {
  PostScan = 1 << 0, PreScan = 1 << 1, LatePostScan = 1 << 2, PreUpdate = 1 << 3,
  PostUpdate = 1 << 4, PostCacheLoad = 1 << 5, PostUpdateBeforeAreaRecalculation = 1 << 6, PostGraphLoad = 1 << 7
}
 GraphModifier event type. More...
 

Public Member Functions

virtual void OnGraphsPostUpdate ()
 Called after graphs have been updated using GraphUpdateObjects or navmesh cutting. More...
 
virtual void OnGraphsPostUpdateBeforeAreaRecalculation ()
 Called after graphs have been updated. More...
 
virtual void OnGraphsPreUpdate ()
 Called before graphs are updated using GraphUpdateObjects. More...
 
virtual void OnLatePostScan ()
 Called at the end of the scanning procedure. More...
 
virtual void OnPostCacheLoad ()
 Called after cached graphs have been loaded. More...
 
virtual void OnPostGraphLoad ()
 Called after a graph has been deserialized and loaded. More...
 
virtual void OnPostScan ()
 Called right after all graphs have been scanned. More...
 
virtual void OnPreScan ()
 Called right before graphs are going to be scanned. More...
 

Static Public Member Functions

static void FindAllModifiers ()
 
static void TriggerEvent (GraphModifier.EventType type)
 Triggers an event for all active graph modifiers. More...
 

Protected Member Functions

override void Awake ()
 
virtual void OnDestroy ()
 
virtual void OnDisable ()
 Removes this modifier from list of active modifiers. More...
 
virtual void OnEnable ()
 Adds this modifier to list of active modifiers. More...
 
override void Reset ()
 Handle serialization backwards compatibility. More...
 
- Protected Member Functions inherited from VersionedMonoBehaviour
virtual int OnUpgradeSerializedData (int version, bool unityThread)
 Handle serialization backwards compatibility. More...
 

Static Protected Member Functions

static List< T > GetModifiersOfType< T > ()
 

Protected Attributes

ulong uniqueID
 Unique persistent ID for this component, used for serialization. More...
 

Static Protected Attributes

static Dictionary< ulong, GraphModifierusedIDs = new Dictionary<ulong, GraphModifier>()
 Maps persistent IDs to the component that uses it. More...
 

Private Member Functions

void AddToLinkedList ()
 
void ConfigureUniqueID ()
 
void RemoveFromLinkedList ()
 

Private Attributes

GraphModifier next
 
GraphModifier prev
 

Static Private Attributes

static GraphModifier root
 All active graph modifiers. More...
 

Additional Inherited Members

- Properties inherited from VersionedMonoBehaviour
int Util.IEntityIndex. EntityIndex [get, set]
 Internal entity index used by #BurstBatchHelper. More...
 
- Properties inherited from IEntityIndex
int EntityIndex [get, set]
 

Member Enumeration Documentation

◆ EventType

enum EventType
strong

GraphModifier event type.

Enumerator
PostScan 
PreScan 
LatePostScan 
PreUpdate 
PostUpdate 
PostCacheLoad 
PostUpdateBeforeAreaRecalculation 
PostGraphLoad 

Member Function Documentation

◆ AddToLinkedList()

void AddToLinkedList ( )
private

◆ Awake()

override void Awake ( )
protectedvirtual

Reimplemented from VersionedMonoBehaviour.

Reimplemented in DynamicGridObstacle.

◆ ConfigureUniqueID()

void ConfigureUniqueID ( )
private

◆ FindAllModifiers()

static void FindAllModifiers ( )
static

◆ GetModifiersOfType< T >()

static List<T> GetModifiersOfType< T > ( )
staticprotected
Type Constraints
T :GraphModifier 

◆ OnDestroy()

virtual void OnDestroy ( )
protectedvirtual

◆ OnDisable()

virtual void OnDisable ( )
protectedvirtual

Removes this modifier from list of active modifiers.

Reimplemented in NodeLink3, DynamicGridObstacle, NodeLink2, and RVONavmesh.

◆ OnEnable()

virtual void OnEnable ( )
protectedvirtual

Adds this modifier to list of active modifiers.

Reimplemented in NodeLink3, and NodeLink2.

◆ OnGraphsPostUpdate()

virtual void OnGraphsPostUpdate ( )
virtual

Called after graphs have been updated using GraphUpdateObjects or navmesh cutting.

This is among other times called after graphs have been scanned, updated using GraphUpdateObjects, navmesh cuts, or GraphUpdateScene components.

Area recalculations (see HierarchicalGraph) have been done at this stage so things like PathUtilities.IsPathPossible will work.

Use OnGraphsPostUpdateBeforeAreaRecalculation instead if you are modifying the graph in any way, especially connections and walkability. This is because if you do this then area recalculations

Reimplemented in RVONavmesh.

◆ OnGraphsPostUpdateBeforeAreaRecalculation()

virtual void OnGraphsPostUpdateBeforeAreaRecalculation ( )
virtual

Called after graphs have been updated.

This is among other times called after graphs have been scanned, updated using GraphUpdateObjects, navmesh cuts, or GraphUpdateScene components.

Note
Area information (see Pathfinding.HierarchicalGraph) may not be up to date when this event is sent. This means some methods like Pathfinding.PathUtilities.IsPathPossible may return incorrect results. Use OnLatePostScan if you need that info to be up to date.

Use this if you are modifying any graph connections or walkability.

See also
OnGraphsPostUpdate

Reimplemented in NodeLink3, NodeLink2, and NodeLink.

◆ OnGraphsPreUpdate()

virtual void OnGraphsPreUpdate ( )
virtual

Called before graphs are updated using GraphUpdateObjects.

◆ OnLatePostScan()

virtual void OnLatePostScan ( )
virtual

Called at the end of the scanning procedure.

This is the absolute last thing done by Scan.

Reimplemented in RVONavmesh.

◆ OnPostCacheLoad()

virtual void OnPostCacheLoad ( )
virtual

Called after cached graphs have been loaded.

When using cached startup, this event is analogous to OnLatePostScan and implementing scripts should do roughly the same thing for both events.

Reimplemented in RVONavmesh.

◆ OnPostGraphLoad()

virtual void OnPostGraphLoad ( )
virtual

Called after a graph has been deserialized and loaded.

Note
The graph may not have had any valid node data, it might just contain the graph settings.

This will be called often outside of play mode. Make sure to check Application.isPlaying if appropriate.

◆ OnPostScan()

virtual void OnPostScan ( )
virtual

Called right after all graphs have been scanned.

Note
Area information (see Pathfinding.HierarchicalGraph) may not be up to date when this event is sent. This means some methods like Pathfinding.PathUtilities.IsPathPossible may return incorrect results. Use OnLatePostScan if you need that info to be up to date.
See also
OnLatePostScan

Reimplemented in GraphUpdateScene, NodeLink3, and DynamicGridObstacle.

◆ OnPreScan()

virtual void OnPreScan ( )
virtual

Called right before graphs are going to be scanned.

See also
OnLatePostScan

◆ RemoveFromLinkedList()

void RemoveFromLinkedList ( )
private

◆ Reset()

override void Reset ( )
protectedvirtual

Handle serialization backwards compatibility.

Reimplemented from VersionedMonoBehaviour.

◆ TriggerEvent()

static void TriggerEvent ( GraphModifier.EventType  type)
static

Triggers an event for all active graph modifiers.

Member Data Documentation

◆ next

GraphModifier next
private

◆ prev

GraphModifier prev
private

◆ root

GraphModifier root
staticprivate

All active graph modifiers.

◆ uniqueID

ulong uniqueID
protected

Unique persistent ID for this component, used for serialization.

◆ usedIDs

Dictionary<ulong, GraphModifier> usedIDs = new Dictionary<ulong, GraphModifier>()
staticprotected

Maps persistent IDs to the component that uses it.


The documentation for this class was generated from the following file: