Search Unity

[Preview 12] 'Job' does not contain a member `Schedule'

Discussion in 'Entity Component System' started by benoneal, Sep 6, 2018.

  1. benoneal

    benoneal

    Joined:
    Apr 15, 2016
    Posts:
    31
    I had the following system working fine in preview 11:

    Code (CSharp):
    1. public class OscillateSystem : JobComponentSystem
    2. {
    3.   [BurstCompile]
    4.   [RequireSubtractiveComponentAttribute(typeof(Pooled))]
    5.   struct OscillateJob : IJobProcessComponentData<Position, Oscillate> {
    6.     public float elapsed;
    7.     public void Execute(ref Position position, [ReadOnly]ref Oscillate o) {
    8.       var clAmped = o.amplitude - o.clamp;
    9.       var wave = o.amplitude * math.sin((2 * math.PI * (1 / o.frequency) * elapsed) + (o.phase * math.PI / 180));
    10.       var offset = (float)math.clamp(wave, clAmped * -1, clAmped);
    11.       position.Value = o.origin + o.axis * offset;
    12.     }
    13.   }
    14.  
    15.   protected override JobHandle OnUpdate(JobHandle inputDeps) {
    16.     var job = new OscillateJob() {elapsed = Time.timeSinceLevelLoad};
    17.     return job.Schedule(this, 32, inputDeps);
    18.   }
    19. }
    I updated to preview 12, and now I'm receiving these errors:

    Assets/OscillateSystem.cs(27,16): error CS0315: The type `OscillateSystem.OscillateJob' cannot be used as type parameter `T' in the generic type or method `Unity.Jobs.IJobParallelForExtensions.Schedule<T>(this T, int, int, Unity.Jobs.JobHandle)'. There is no boxing conversion from `OscillateSystem.OscillateJob' to `Unity.Jobs.IJobParallelFor'

    Assets/OscillateSystem.cs(27,16): error CS1928: Type `OscillateSystem.OscillateJob' does not contain a member `Schedule' and the best extension method overload `Unity.Jobs.IJobParallelForExtensions.Schedule<OscillateSystem.OscillateJob>(this OscillateSystem.OscillateJob, int, int, Unity.Jobs.JobHandle)' has some invalid arguments

    I'd appreciate any help, as I'm new to both C# and Unity (and ECS).

    Also while I'm here... are there any guidelines about what a good batch count is for the job scheduling? Should it be approximately the number of entities / number of cores? Does it have to be a power of 2? Is there a penalty for too large batches, or too small, and if so, any rule of thumb for finding the "sweet spot"?

    Thanks.
     
  2. julian-moschuering

    julian-moschuering

    Joined:
    Apr 15, 2014
    Posts:
    529
  3. benoneal

    benoneal

    Joined:
    Apr 15, 2016
    Posts:
    31
    Ah thanks @julian-moschuering ! I actually checked the release notes last night after I updated to preview 12, but they hadn't been updated by then. Should have checked again today.