Hi, I'm having some trouble in Entities 1.0.0-pre.15.
I want to create a generic job for dealing with components that have a limited lifetime. I've learned that IJobEntity's code generation does not support generic jobs, but it should theoretically be possible to write my own IJobChunk. However, I'm getting a persistent error that I have not been able to solve.
A minimal version of the job code in question is
using Unity.Entities;
using Unity.Burst;
using Unity.Burst.Intrinsics;
using Unity.Collections;
[BurstCompile]
public partial struct StatusCountdownJob<T> : IJobChunk
where T : struct, IComponentData, IStatus
{
ComponentTypeHandle<T> StatusHandle;
public void Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask) {
NativeArray<T> statuses = chunk.GetNativeArray<T>(ref StatusHandle);
for (int i = 0; i < chunk.Count; ++i)
{
// do stuff
}
}
}
IStatus is:
using Unity.Entities;
public interface IStatus : IComponentData
{
public float TimeRemaining { get; set; }
}
however removing it from the generic type does not fix the error.
The resulting error is:
Assets/Scripts/GenericJobs/StatusCountdownJob.cs(21,41): error CS8377: The type 'T' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'T' in the generic type or method 'ArchetypeChunk.GetNativeArray<T>(ref ComponentTypeHandle<T>)'
I believe that declaring thatTmust be a struct should already make it a non-nullable value type, so I'm not sure why I'm getting this error.
Please could I ask for some advice solving this?