Add methods to add several Transforms to a TransformAccessArray

The following type contains a constructor with the signature:

public TransformAccessArray(Transform[] transforms, int desiredJobCount);

I propose adding the overloads to the constructor:

public TransformAccessArray(ReadOnlySpan<Transform> transforms, int desiredJobCount);
public TransformAccessArray(List<Transform> transforms, int desiredJobCount);

And the following overloads to the method:

public void SetTransforms(ReadOnlySpan<Transform> transforms);
public void SetTransforms(List<Transform> transforms);

And the new method:

public void AddRange(Transform[] transforms);
public void AddRange(ReadOnlySpan<Transform> transforms);
public void AddRange(List<Transform> transforms);

Alternatively, adding overloads that accept count would also be useful such as:

public void SetTransforms(Transform[] transforms, int count)

So you can specify how many items you want to set.

This would make it easier to construct TransformAccessArray with populated results.
Of course, you can right now emulate them by iterating the collection and using the Add method, or creating a new array with the specific size, but that is more expensive due to potential allocations, safety checks, and/or internal calls.

Having that additional overloads would make stuff easier and more performant, and they are trivial to implement.

7 Likes

I still don’t understand why literally everything related to job system have overloads for everything, meanwhile TransformAccessArray content manipulation is so poor and mysterious.

Yes, but doing that would make sense.