Search Unity

[SOLVED] Job doesnt get executed. [PLEASE DELETE]

Discussion in 'Entity Component System' started by illinar, Dec 13, 2018.

  1. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    Code (CSharp):
    1. public class LocalGravitySystem : JobComponentSystem
    2. {
    3.     [Inject] ReadonlyInjection<Gravity> _gravity;
    4.  
    5.     // [BurstCompile]
    6.     struct Job : IJobProcessComponentData<Velocity, AffectedByGravity>
    7.     {
    8.         public float deltaTime;
    9.         public Gravity gravity;
    10.         public void Execute(ref Velocity velocity, [ReadOnly] ref AffectedByGravity affected)
    11.         {
    12.             Debug.Log("doesn't reach here");
    13.             velocity.Value = float3.zero;//+= gravity.Value * (affected.EffectScale * deltaTime);
    14.         }
    15.     }
    16.  
    17.     protected override JobHandle OnUpdate(JobHandle inputDeps)
    18.     {
    19.         if (_gravity)
    20.         {
    21.             var job = new Job { deltaTime = Time.deltaTime, gravity = _gravity.Components[0] };
    22.             Debug.Log("reaches here");
    23.             return job.Schedule(this, inputDeps);
    24.         }
    25.         else
    26.             return inputDeps;
    27.     }
    28. }
    Gets scheduled as far as I can tell, but is never executed. I'm out of ideas. Please help.

    Ahh. Not again! I used a wrong Velocity component. :)
     
    Last edited: Dec 13, 2018