A* Pathfinding Project
4.1.6
The A* Pathfinding Project for Unity 3D
|
Base class for all graphs. More...
Base class for all graphs.
Public Member Functions | |
virtual int | CountNodes () |
Number of nodes in the graph. | |
NNInfoInternal | GetNearest (Vector3 position) |
Returns the nearest node to a position using the default NNConstraint. | |
NNInfoInternal | GetNearest (Vector3 position, NNConstraint constraint) |
Returns the nearest node to a position using the specified NNConstraint. | |
virtual NNInfoInternal | GetNearest (Vector3 position, NNConstraint constraint, GraphNode hint) |
Returns the nearest node to a position using the specified NNConstraint. | |
virtual NNInfoInternal | GetNearestForce (Vector3 position, NNConstraint constraint) |
Returns the nearest node to a position using the specified constraint . | |
void | GetNodes (System.Func< GraphNode, bool > action) |
Calls a delegate with all nodes in the graph until the delegate returns false. | |
abstract void | GetNodes (System.Action< GraphNode > action) |
Calls a delegate with all nodes in the graph. | |
virtual void | OnDrawGizmos (RetainedGizmos gizmos, bool drawNodes) |
Draw gizmos for the graph. | |
void | RelocateNodes (Matrix4x4 oldMatrix, Matrix4x4 newMatrix) |
Moves nodes in this graph. | |
virtual void | RelocateNodes (Matrix4x4 deltaMatrix) |
Moves the nodes in this graph. | |
void | Scan () |
Scan the graph. | |
void | ScanGraph () |
Scan the graph. | |
void | SetMatrix (Matrix4x4 m) |
Use to set both matrix and inverseMatrix at the same time. | |
Public Member Functions inherited from IGraphInternals | |
void | DeserializeExtraInfo (GraphSerializationContext ctx) |
void | DeserializeSettingsCompatibility (GraphSerializationContext ctx) |
void | DestroyAllNodes () |
void | OnDestroy () |
void | PostDeserialization (GraphSerializationContext ctx) |
IEnumerable< Progress > | ScanInternal () |
void | SerializeExtraInfo (GraphSerializationContext ctx) |
Public Attributes | |
AstarPath | active |
Reference to the AstarPath object in the scene. | |
bool | drawGizmos = true |
Enable to draw gizmos in the Unity scene view. | |
uint | graphIndex |
Index of the graph, used for identification purposes. | |
Guid | guid |
Used as an ID of the graph, considered to be unique. | |
bool | infoScreenOpen |
Used in the editor to check if the info screen is open. | |
uint | initialPenalty |
Default penalty to apply to all nodes. | |
Matrix4x4 | inverseMatrix = Matrix4x4.identity |
Inverse of matrix. | |
Matrix4x4 | matrix = Matrix4x4.identity |
A matrix for translating/rotating/scaling the graph. | |
string | name |
Name of the graph. | |
bool | open |
Is the graph open in the editor. | |
Protected Member Functions | |
virtual void | DeserializeExtraInfo (GraphSerializationContext ctx) |
Deserializes graph type specific node data. | |
virtual void | DeserializeSettingsCompatibility (GraphSerializationContext ctx) |
An old format for serializing settings. | |
virtual void | DestroyAllNodes () |
Destroys all nodes in the graph. | |
void | DrawUnwalkableNodes (float size) |
virtual void | OnDestroy () |
Function for cleaning up references. | |
virtual void | PostDeserialization (GraphSerializationContext ctx) |
Called after all deserialization has been done for all graphs. | |
abstract IEnumerable< Progress > | ScanInternal () |
Internal method to scan the graph. | |
virtual void | SerializeExtraInfo (GraphSerializationContext ctx) |
Serializes graph type specific node data. | |
Properties | |
bool | exists [get] |
True if the graph exists, false if it has been destroyed. | |
Private Member Functions | |
void IGraphInternals. | DeserializeExtraInfo (GraphSerializationContext ctx) |
void IGraphInternals. | DeserializeSettingsCompatibility (GraphSerializationContext ctx) |
void IGraphInternals. | DestroyAllNodes () |
void IGraphInternals. | OnDestroy () |
void IGraphInternals. | PostDeserialization (GraphSerializationContext ctx) |
IEnumerable< Progress > IGraphInternals. | ScanInternal () |
void IGraphInternals. | SerializeExtraInfo (GraphSerializationContext ctx) |
|
virtual |
Number of nodes in the graph.
Note that this is, unless the graph type has overriden it, an O(n) operation.
This is an O(1) operation for grid graphs and point graphs. For layered grid graphs it is an O(n) operation.
Reimplemented in GridGraph, PointGraph, and LayerGridGraph.
|
protectedvirtual |
Deserializes graph type specific node data.
Reimplemented in GridGraph, NavmeshBase, LayerGridGraph, and PointGraph.
|
private |
|
protectedvirtual |
An old format for serializing settings.
Reimplemented in GridGraph, RecastGraph, PointGraph, and NavMeshGraph.
|
private |
|
protectedvirtual |
Destroys all nodes in the graph.
Reimplemented in GridGraph.
|
private |
|
protected |
NNInfoInternal GetNearest | ( | Vector3 | position | ) |
Returns the nearest node to a position using the default NNConstraint.
position | The position to try to find a close node to |
NNInfoInternal GetNearest | ( | Vector3 | position, |
NNConstraint | constraint | ||
) |
Returns the nearest node to a position using the specified NNConstraint.
position | The position to try to find a close node to |
constraint | Can for example tell the function to try to return a walkable node. If you do not get a good node back, consider calling GetNearestForce. |
|
virtual |
Returns the nearest node to a position using the specified NNConstraint.
position | The position to try to find a close node to |
hint | Can be passed to enable some graph generators to find the nearest node faster. |
constraint | Can for example tell the function to try to return a walkable node. If you do not get a good node back, consider calling GetNearestForce. |
Reimplemented in GridGraph, LayerGridGraph, NavmeshBase, and PointGraph.
|
virtual |
Returns the nearest node to a position using the specified constraint .
Reimplemented in GridGraph, LayerGridGraph, NavmeshBase, and PointGraph.
void GetNodes | ( | System.Func< GraphNode, bool > | action | ) |
Calls a delegate with all nodes in the graph until the delegate returns false.
|
pure virtual |
Calls a delegate with all nodes in the graph.
This is the primary way of iterating through all nodes in a graph.
Do not change the graph structure inside the delegate.
If you want to store all nodes in a list you can do this
Implemented in NavmeshBase, GridGraph, PointGraph, and LayerGridGraph.
|
protectedvirtual |
Function for cleaning up references.
This will be called on the same time as OnDisable on the gameObject which the AstarPath script is attached to (remember, not in the editor). Use for any cleanup code such as cleaning up static variables which otherwise might prevent resources from being collected. Use by creating a function overriding this one in a graph class, but always call base.OnDestroy () in that function. All nodes should be destroyed in this function otherwise a memory leak will arise.
Reimplemented in NavmeshBase, GridGraph, and LayerGridGraph.
|
private |
|
virtual |
Draw gizmos for the graph.
Reimplemented in GridGraph.
|
protectedvirtual |
Called after all deserialization has been done for all graphs.
Can be used to set up more graph data which is not serialized
Reimplemented in GridGraph, NavmeshBase, LayerGridGraph, and PointGraph.
|
private |
void RelocateNodes | ( | Matrix4x4 | oldMatrix, |
Matrix4x4 | newMatrix | ||
) |
Moves nodes in this graph.
|
virtual |
Moves the nodes in this graph.
Multiplies all node positions by deltaMatrix.
For example if you want to move all your nodes in e.g a point graph 10 units along the X axis from the initial position
Reimplemented in PointGraph, GridGraph, and NavmeshBase.
void Scan | ( | ) |
Scan the graph.
Consider using AstarPath.Scan() instead since this function only scans this graph and if you are using multiple graphs with connections between them, then it is better to scan all graphs at once.
void ScanGraph | ( | ) |
Scan the graph.
|
protectedpure virtual |
Internal method to scan the graph.
Called from AstarPath.ScanAsync. Override this function to implement custom scanning logic. Progress objects can be yielded to show progress info in the editor and to split up processing over several frames when using async scanning.
Implemented in GridGraph, RecastGraph, LayerGridGraph, PointGraph, and NavMeshGraph.
|
private |
|
protectedvirtual |
Serializes graph type specific node data.
This function can be overriden to serialize extra node information (or graph information for that matter) which cannot be serialized using the standard serialization. Serialize the data in any way you want and return a byte array. When loading, the exact same byte array will be passed to the DeserializeExtraInfo function.
These functions will only be called if node serialization is enabled.
Reimplemented in GridGraph, NavmeshBase, LayerGridGraph, and PointGraph.
|
private |
void SetMatrix | ( | Matrix4x4 | m | ) |
Use to set both matrix and inverseMatrix at the same time.
bool drawGizmos = true |
Enable to draw gizmos in the Unity scene view.
In the inspector this value corresponds to the state of the 'eye' icon in the top left corner of every graph inspector.
uint graphIndex |
Index of the graph, used for identification purposes.
Guid guid |
Used as an ID of the graph, considered to be unique.
bool infoScreenOpen |
Used in the editor to check if the info screen is open.
Should be inside UNITY_EDITOR only #ifs but just in case anyone tries to serialize a NavGraph instance using Unity, I have left it like this as it would otherwise cause a crash when building. Version 3.0.8.1 was released because of this bug only
uint initialPenalty |
Default penalty to apply to all nodes.
Matrix4x4 inverseMatrix = Matrix4x4.identity |
Inverse of matrix.
Matrix4x4 matrix = Matrix4x4.identity |
A matrix for translating/rotating/scaling the graph.
string name |
Name of the graph.
Can be set in the unity editor
bool open |
Is the graph open in the editor.
|
getpackage |
True if the graph exists, false if it has been destroyed.