I want to have a IJobFor that has a NativeArray of an interface. The reason is that I am doing mesh operations and want to fill the array with different operations to execute on the mesh in order (Bend, twist, offset, etc).
So the job will iterate over each vertex in a mesh, and iterate over each operation, executing it on the vertex.
Something sort of like this (there would be more to it than this, but this is the basic idea I was thinking of).
Of course you can't have an NativeArray of interfaces, so what would be the solution here?
interface IMeshOperator {
void Operate(int vertexIndex);
}
struct MeshJob : IJobFor {
public NativeArray<IMeshOperator> operations;
public void Execute(int index)
{
for (int i = 0; i < operations.Length; i++) {
operations[i].Operate(index);
}
}
}