A* Pathfinding Project  3.0.9
The A* Pathfinding Project for Unity
AstarData Class Reference

Stores the navgraphs for the A* Pathfinding System. More...

+ Collaboration diagram for AstarData:

List of all members.

Public Member Functions

void UpdateShortcuts ()  
void Awake ()  Loads the graphs from memory, will load cached graphs if any exists.
void LoadFromCache ()  
void SaveCacheData (int mask)  
byte[] SerializeGraphs (AstarSerializer serializer)  Main serializer function, a similar one exists in the AstarEditor.cs script to save additional info.
void SerializeGraphsPart (AstarSerializer serializer)  Saves all graphs and also user connections, but does not close, nor opens the stream.
void DeserializeGraphs (AstarSerializer serializer)  Main deserializer function, loads from the #data variable.
void DeserializeGraphs (AstarSerializer serializer, byte[] bytes)  Main deserializer function, loads from bytes variable.
void DeserializeGraphsPart (AstarSerializer serializer)  Deserializes all graphs and also user connections.
void FindGraphTypes ()  Find all graph types supported in this build.
System.Type GetGraphType (string type)  
NavGraph CreateGraph (string type)  Creates a new instance of a graph of type type.
NavGraph CreateGraph (System.Type type)  Creates a new graph instance of type type.
NavGraph AddGraph (string type)  Adds a graph of type type to the graphs array.
NavGraph AddGraph (System.Type type)  Adds a graph of type type to the graphs array.
void AddGraph (NavGraph graph)  Adds the specified graph to the graphs array.
void RemoveGraph (NavGraph graph)  Removes the specified graph from the graphs array and Destroys it in a safe manner.
Node GetNode (int graphIndex, int nodeIndex)  Returns the node at graphs[graphIndex].nodes[nodeIndex].
Node GetNode (int graphIndex, int nodeIndex, NavGraph[] graphs)  Returns the node at graphs[graphIndex].nodes[nodeIndex].
NavGraph FindGraphOfType (System.Type type)  Returns the first graph of type type found in the graphs array.
IEnumerable FindGraphsOfType (System.Type type)  Loop through this function to get all graphs of type 'type'.
IEnumerable GetUpdateableGraphs ()  All graphs which implements the UpdateableGraph interface.
IEnumerable GetRaycastableGraphs ()  All graphs which implements the UpdateableGraph interface.
int GetGraphIndex (NavGraph graph)  Gets the index of the NavGraph in the graphs array.
int GuidToIndex (System.Guid guid)  Tries to find a graph with the specified GUID in the graphs array.
NavGraph GuidToGraph (System.Guid guid)  Tries to find a graph with the specified GUID in the graphs array.

Static Public Member Functions

static NavGraph GetGraph (Node node)  Returns the graph which contains the specified node.

Public Variables

NavMeshGraph navmesh  Shortcut to the first NavMeshGraph.
GridGraph gridGraph  Shortcut to the first GridGraph.
ListGraph listGraph  Shortcut to the first ListGraph.
System.Type[] graphTypes = null  All supported graph types.
NavGraph[] graphs  All graphs this instance holds.
UserConnection[] userConnections  Links placed by the user in the scene view.
bool hasBeenReverted = false  Has the data been reverted by an undo operation.
byte[] data  
byte[] data_backup  
byte[] data_cachedStartup  
bool cacheStartup = false  
bool compress = false  

Properties

AstarPath active [get]  

Detailed Description

Stores the navgraphs for the A* Pathfinding System.

An instance of this class is assigned to AstarPath::astarData, from it you can access all graphs loaded through graphs.
This class also handles a lot of the high level serialization.


Member Function Documentation

NavGraph AddGraph ( string  type)

Adds a graph of type type to the graphs array.

NavGraph AddGraph ( System.Type  type)

Adds a graph of type type to the graphs array.

void AddGraph ( NavGraph  graph)

Adds the specified graph to the graphs array.

void Awake ( )

Loads the graphs from memory, will load cached graphs if any exists.

NavGraph CreateGraph ( string  type)

Creates a new instance of a graph of type type.

If no matching graph type was found, an error is logged and null is returned

Returns:
The created graph
See also:
CreateGraph(System.Type)
NavGraph CreateGraph ( System.Type  type)

Creates a new graph instance of type type.

See also:
CreateGraph(string)
void DeserializeGraphs ( AstarSerializer  serializer)

Main deserializer function, loads from the #data variable.

void DeserializeGraphs ( AstarSerializer  serializer,
byte[]  bytes 
)

Main deserializer function, loads from bytes variable.

void DeserializeGraphsPart ( AstarSerializer  serializer)

Deserializes all graphs and also user connections.

NavGraph FindGraphOfType ( System.Type  type)

Returns the first graph of type type found in the graphs array.

Returns null if none was found

IEnumerable FindGraphsOfType ( System.Type  type)

Loop through this function to get all graphs of type 'type'.

 foreach (GridGraph graph in AstarPath.astarData.FindGraphsOfType (typeof(GridGraph))) {
    //Do something with the graph
 } 
See also:
AstarPath::RegisterSafeNodeUpdate
void FindGraphTypes ( )

Find all graph types supported in this build.

Using reflection, the assembly is searched for types which inherit from NavGraph.

static NavGraph GetGraph ( Node  node) [static]

Returns the graph which contains the specified node.

The graph must be in the graphs array.

Returns:
Returns the graph which contains the node. Null if the graph wasn't found
int GetGraphIndex ( NavGraph  graph)

Gets the index of the NavGraph in the graphs array.

System.Type GetGraphType ( string  type)
Returns:
A System.Type which matches the specified type string. If no mathing graph type was found, null is returned
Node GetNode ( int  graphIndex,
int  nodeIndex 
)

Returns the node at graphs[graphIndex].nodes[nodeIndex].

All kinds of error checking is done to make sure no exceptions are thrown.

Node GetNode ( int  graphIndex,
int  nodeIndex,
NavGraph[]  graphs 
)

Returns the node at graphs[graphIndex].nodes[nodeIndex].

The graphIndex refers to the specified graphs array.
All kinds of error checking is done to make sure no exceptions are thrown

IEnumerable GetRaycastableGraphs ( )

All graphs which implements the UpdateableGraph interface.

 foreach (IRaycastableGraph graph in AstarPath.astarData.GetRaycastableGraphs ()) {
    //Do something with the graph
 } 
See also:
Pathfinding::IRaycastableGraph
IEnumerable GetUpdateableGraphs ( )

All graphs which implements the UpdateableGraph interface.

 foreach (IUpdatableGraph graph in AstarPath.astarData.GetUpdateableGraphs ()) {
    //Do something with the graph
 } 
See also:
AstarPath::RegisterSafeNodeUpdate
Pathfinding::IUpdatableGraph
NavGraph GuidToGraph ( System.Guid  guid)

Tries to find a graph with the specified GUID in the graphs array.

Returns null if none is found

See also:
GuidToIndex
int GuidToIndex ( System.Guid  guid)

Tries to find a graph with the specified GUID in the graphs array.

if one is found it returns its index, otherwise it returns -1

See also:
GuidToGraph
void RemoveGraph ( NavGraph  graph)

Removes the specified graph from the graphs array and Destroys it in a safe manner.

byte [] SerializeGraphs ( AstarSerializer  serializer)

Main serializer function, a similar one exists in the AstarEditor.cs script to save additional info.

void SerializeGraphsPart ( AstarSerializer  serializer)

Saves all graphs and also user connections, but does not close, nor opens the stream.


Member Data Documentation

All graphs this instance holds.

This will be filled only after deserialization has completed

System.Type [] graphTypes = null

All supported graph types.

This should be identical throughout the project

Shortcut to the first GridGraph.

Updated at scanning time

bool hasBeenReverted = false

Has the data been reverted by an undo operation.

Used by the editor's undo logic to check if the AstarData has been reverted by an undo operation and should be deserialized

Shortcut to the first ListGraph.

Updated at scanning time

Shortcut to the first NavMeshGraph.

Updated at scanning time

Links placed by the user in the scene view.


The documentation for this class was generated from the following file:
 All Classes Functions Variables Enumerations Properties