Skip to content

Game.Pathfind.DeleteAction

Assembly: Assembly-CSharp.dll
Namespace: Game.Pathfind

Type: struct (implements System.IDisposable)

Base: System.ValueType

Summary:
DeleteAction is a small value-type container used by the pathfinding system to hold an array of DeleteActionData entries. It wraps a Unity.Collections.NativeArray and provides a constructor for allocating that array and a Dispose method to release its native memory. This type is intended for transient use in pathfinding code and jobs; callers must manage NativeArray lifetime explicitly and ensure disposal happens only after any jobs that use the array have completed.


Fields

  • public Unity.Collections.NativeArray<DeleteActionData> m_DeleteData
    Holds the DeleteActionData entries. The array is allocated by the constructor with the provided Allocator. Because this is a NativeArray, it refers to unmanaged memory that must be freed by calling Dispose on the DeleteAction (or directly on the NativeArray) when it is no longer needed. When passing m_DeleteData to jobs, ensure JobHandle completion before disposing.

Properties

  • None.

Constructors

  • public DeleteAction(int size, Allocator allocator)
    Allocates m_DeleteData as a NativeArray with the specified length and allocator. The size parameter should match the number of delete entries you intend to store. Choose an appropriate Allocator (for example, Allocator.TempJob for short-lived arrays used by scheduled jobs, or Allocator.Persistent for long-lived storage).

Methods

  • public void Dispose()
    Disposes the internal NativeArray by calling m_DeleteData.Dispose(). Do not call Dispose while jobs that use the array are still running; wait for the job's JobHandle to Complete() first.

Usage Example

using Unity.Collections;
using Unity.Jobs;

// Create for short-lived use in a job
var deleteAction = new Game.Pathfind.DeleteAction(128, Allocator.TempJob);

// Fill entries (example)
for (int i = 0; i < deleteAction.m_DeleteData.Length; i++)
{
    // deleteAction.m_DeleteData[i] = new DeleteActionData { ... };
}

// If you schedule a job that uses deleteAction.m_DeleteData, capture the JobHandle:
JobHandle handle = somePathfindingJob.Schedule();

// Ensure the job is complete before disposing the native array
handle.Complete();
deleteAction.Dispose();

// Or, if you don't use jobs, dispose directly when done
// deleteAction.Dispose();

Additional notes: - Always match the Allocator choice to the lifetime of the data and Unity job usage rules. - If you pass m_DeleteData to jobs, be careful about concurrent access and use appropriate attributes or synchronization patterns as needed. - Because DeleteAction is a struct, you can use it in a using statement (C# 8 using declaration or using(...) block) to auto-dispose, but still must ensure no jobs access the NativeArray after disposal.