Error with IJobForEach

So, i have this script:

namespace Game.Systems {
   using Unity.Entities;
   using Unity.Burst;
   using Game.Data;
   using Unity.Jobs;
   using UnityEngine;

   public class InputSystem : JobComponentSystem {
      [BurstCompile]
      struct InputJob : IJobForEach<InputData> {
         public float horizontalAxis;
         public float verticalAxis;

         public void Execute(ref InputData inputData) {
            inputData.Horizontal = horizontalAxis;
            inputData.Vertical = verticalAxis;
         }
      }

      protected override JobHandle OnUpdate(JobHandle inputDeps) {
         InputJob job = new InputJob() {
            horizontalAxis = Input.GetAxis("Horizontal"),
            verticalAxis = Input.GetAxis("Vertical")
         };

         return job.Schedule(this, inputDeps);
      }
   }
}

and i’m receiving this error:


when i remove the interface the error goes away, so i don’t know what to do.
Is this an error in this interface or am i doing something wrong?

I followed the example in Using IJobForEach | Package Manager UI website

InputData needs to be a struct instead of a class. In addition, the InputData struct cannot have unmanaged fields.

thank you. i feel ashame of finding github and finding that InputData needs to be IComponentData.

Thank you for reply.

No shame in making mistakes mate.

1 Like