Class PlatformerGraphPopulator
Utility to populate PlatformerGraph using Unity's Job system. This can be useful if you have frequent updates and want this process to be as fast as possible and/or on another thread.
Namespace: AnyPath.Graphs.PlatformerGraph
Assembly: AnyPath.dll
Syntax
public static class PlatformerGraphPopulator
Remarks
Works in the same manner as the NavMeshPopulator
Methods
SchedulePopulate(PlatformerGraph, NativeArray<float2>, NativeArray<Edge>, NativeArray<Edge>, JobHandle)
Schedules a job that populates the PlatformerGraph with undirected edges and directed edges
Declaration
public static JobHandle SchedulePopulate(this PlatformerGraph graph, NativeArray<float2> vertices, NativeArray<PlatformerGraph.Edge> undirectedEdges, NativeArray<PlatformerGraph.Edge> directedEdges, JobHandle dependsOn = default)
Parameters
| Type | Name | Description |
|---|---|---|
| PlatformerGraph | graph | |
| NativeArray<float2> | vertices | |
| NativeArray<PlatformerGraph.Edge> | undirectedEdges | |
| NativeArray<PlatformerGraph.Edge> | directedEdges | |
| JobHandle | dependsOn |
Returns
| Type | Description |
|---|---|
| JobHandle |
Examples
// Example on how to weld vertices and populate the PlatformerGraph using Unity's Job system
// these NativeLists and arrays will be modified in place
var weldHandle = PlatformerGraphWelder.ScheduleWeld(vertices, directedEdges, undirectedEdges);
// Schedule the populate job with a dependency on the weld job handle
// Pass in the welded verts as a deffered array
var populateHandle =
PlatformerGraphPopulator.SchedulePopulate(graph, vertices.AsDeferredJobArray(), undirectedEdges, directedEdges, weldHandle);
// complete the job, or wait for the result somewhere else
populateHandle.Complete();
SchedulePopulate(PlatformerGraph, NativeArray<float2>, NativeArray<Edge>, JobHandle)
Schedules a job that populates the PlatformerGraph with only undirected edges
Declaration
public static JobHandle SchedulePopulate(this PlatformerGraph graph, NativeArray<float2> vertices, NativeArray<PlatformerGraph.Edge> undirectedEdges, JobHandle dependsOn = default)
Parameters
| Type | Name | Description |
|---|---|---|
| PlatformerGraph | graph | |
| NativeArray<float2> | vertices | |
| NativeArray<PlatformerGraph.Edge> | undirectedEdges | |
| JobHandle | dependsOn |
Returns
| Type | Description |
|---|---|
| JobHandle |
Examples
// Example on how to weld vertices and populate the PlatformerGraph using Unity's Job system
// these NativeLists and arrays will be modified in place
var weldHandle = PlatformerGraphWelder.ScheduleWeld(vertices, directedEdges);
// Schedule the populate job with a dependency on the weld job handle
// Pass in the welded verts as a deffered array
var populateHandle =
PlatformerGraphPopulator.SchedulePopulate(graph, vertices.AsDeferredJobArray(), undirectedEdges, weldHandle);
// complete the job, or wait for the result somewhere else
populateHandle.Complete();