Search Unity

Help Wanted Dependency Issue.

Discussion in 'Data Oriented Technology Stack' started by francois85, Jul 17, 2021.

  1. francois85

    francois85

    Joined:
    Aug 11, 2015
    Posts:
    1,634
    I don't understand why this is an issue? Please help me understand.

    Code (CSharp):
    1. InvalidOperationException: The system TCC.ECS.Refactor.AuthoringRefactor.GraphSystem reads TCC.ECS.Refactor.AuthoringRefactor.ReferenceGraphDescriptorComponent via GraphSystem:GraphSystem_GraphInputRecorderComponent_UpdateData but that type was not assigned to the Dependency property. To ensure correct behavior of other systems, the job or a dependency must be assigned to the Dependency property before returning from the OnUpdate method.
    2.  
    Code (CSharp):
    1.  
    2.  
    3. var dept0 = Entities
    4.     .WithName($"GraphSystem_GraphInputRecorderComponent_UpdateData")
    5.     .ForEach((Entity e, ref GraphInputRecorderComponent gi, in ReferenceGraphDescriptorComponent d) =>
    6.     {
    7.         Debug.Log($"GraphSystem_GraphInputRecorderComponent_UpdateData");
    8.        
    9.         var graphMaxCapacityX = GetComponent<GraphDescriptorComponent>(d.GraphDescriptorEntity).MaxCapacityX;
    10.         var graphMaxCapacityZ = GetComponent<GraphDescriptorComponent>(d.GraphDescriptorEntity).MaxCapacityZ;
    11.         float3 intersectPoint = float3.zero;
    12.         float3 px = new float3(0f, 0f, -500f);
    13.         float3 py = new float3(0f, 0f, graphMaxCapacityX*2);  
    14.         float3 pz = new float3(graphMaxCapacityZ*4, 0f, -500f);
    15.        
    16.         bool hit = RayIntersectionUtils.Intersect
    17.         (
    18.             graphInputData.PointerWorldPosition,
    19.             graphInputData.PointerCameraRayDirection,
    20.             px,
    21.             py,
    22.             pz,
    23.             ref intersectPoint
    24.         );
    25.  
    26.         gi.Hit = hit;
    27.         gi.LatestInputRayHitPosition = intersectPoint;
    28.     }).Schedule(Dependency);
    29.  
     
  2. RahulRaman

    RahulRaman

    Joined:
    Oct 5, 2019
    Posts:
    2
    The Unity_Entities_SystemBase_Dependency section shows exactly how to manage the dependency of the system when explicitly assigning the dependency JobHandle to the Entities.ForEach call.

    So if you manually assign the dependency to the Entities.ForEach call you should set the system's Dependency attribute after the call, like:
    Code (CSharp):
    1. var dep= Entities.ForEach(
    2.                 (ref Translation translation) =>
    3.                 {
    4.                     /*Some logic here*/
    5.                 }).Schedule(Dependency);
    6.             this.Dependency = dep;
    I too once got the same error when I manually assigned the dependency property to Entities.ForEach calls in my system which inherited from SystemBase, and setting the ForEach call's job handle to the Dependency attribute fixed it.
     
  3. francois85

    francois85

    Joined:
    Aug 11, 2015
    Posts:
    1,634
    Yep this was it , thank you
     
unityunity