A* Pathfinding Project  4.1.7
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.

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

Public Types

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

Public Member Functions

virtual void OnGraphsPostUpdate ()
 Called after graphs have been updated using GraphUpdateObjects. 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 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...
 
- 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 ()
 
void Reset ()
 

Private Attributes

GraphModifier next
 
GraphModifier prev
 

Static Private Attributes

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

Member Enumeration Documentation

◆ EventType

enum EventType
strong

GraphModifier event type.

Enumerator
PostScan 
PreScan 
LatePostScan 
PreUpdate 
PostUpdate 
PostCacheLoad 

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

Reimplemented in DynamicGridObstacle.

◆ OnDisable()

virtual void OnDisable ( )
protectedvirtual

Removes this modifier from list of active modifiers.

Reimplemented in NodeLink3, 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.

Eventual flood filling has been done

Reimplemented in NodeLink3, NodeLink2, NodeLink, and RVONavmesh.

◆ 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.

◆ OnPostScan()

virtual void OnPostScan ( )
virtual

Called right after all graphs have been scanned.

FloodFill and other post processing has not been done.

Warning
Since OnEnable and Awake are called roughly in the same time, the only way to ensure that these scripts get this call when scanning in Awake is to set the Script Execution Order for AstarPath to some time later than default time (see Edit -> Project Settings -> Script Execution Order).
Todo:
Is this still relevant? A call to FindAllModifiers should have before this method is called so the above warning is probably not relevant anymore.
See also
OnLatePostScan

Reimplemented in GraphUpdateScene, NodeLink3, NodeLink2, DynamicGridObstacle, and NodeLink.

◆ OnPreScan()

virtual void OnPreScan ( )
virtual

Called right before graphs are going to be scanned.

Warning
Since OnEnable and Awake are called roughly in the same time, the only way to ensure that these scripts get this call when scanning in Awake is to set the Script Execution Order for AstarPath to some time later than default time (see Edit -> Project Settings -> Script Execution Order).
Todo:
Is this still relevant? A call to FindAllModifiers should have before this method is called so the above warning is probably not relevant anymore.
See also
OnLatePostScan

◆ RemoveFromLinkedList()

void RemoveFromLinkedList ( )
private

◆ Reset()

void Reset ( )
private

◆ 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: