Function AstarPath.AllocateNodes

AllocateNodes<T> (T[] result, int count, System.Func<T> createNode, uint variantsPerNode)

Allocate a bunch of nodes at once.

Public
Unity.Jobs.JobHandle AllocateNodes<T> (

T[]

result

Node array to fill

int

count

How many nodes to allocate

System.Func<T>

createNode

Delegate which creates a node. () => new T(). Note that new T(AstarPath.active) should *not* be used as that will cause the node to be initialized twice.

uint

variantsPerNode

How many variants of the node to allocate. Should be the same as GraphNode.PathNodeVariants for this node type.

)

Allocate a bunch of nodes at once.

This is faster than allocating each individual node separately and it can be done in a separate thread by using jobs.

var nodes = new PointNode[128];
var job = AstarPath.active.AllocateNodes(nodes, 128, () => new PointNode(), 1);

job.Complete();