Burst Job inside of generic class?

I have a job that exists inside of a generic class, which I’m trying to burst compile:

    // serializer concrete class which takes type arguments
    public class Serializer<T0> : Serializer where T0 : struct, IComponentData {

      [BurstCompile]
      struct Job : IJobChunk {
        // type that signifies a networked entity
        [ReadOnly] public ArchetypeChunkComponentType<NetworkedEntity> NetworkedComponentType;

        // the component this job serializes
        [ReadOnly] public ArchetypeChunkComponentType<T0> TargetComponentType;

       // ... snip

The Serializer class instances are created using reflection and hosted in a system, but they are not systems themselves. Two things I’ve “Noticed”:

  1. The unity editor or player will hard crash whenever I run this code (works fine without [BurstCompile])
  2. The job does not show up in the burst inspector so I’m assuming it’s not even burst compiled

The only think I found in doc is:


Maybe change it to
public struct Serializer<T0> : Serializer where T0 : IComponentData

Maybe this is interesting to you:

I’ve implemented a system that creates and calls generic JobComponentData based on a specific interfaces that components have to be implemented. The only thing is that you have to define your generic job outside of the system because of a bug in ECS.

(Second Post!)

I’m not sure it is your issue above… but Burst does not support today to have generic abstraction around job.schedule, so all jobs scheduled need to have an explicit usage of their type.

1 Like

Yes this was my issue - moved well past this :slight_smile: thanks for the reply, but this thread is from January? :smile: