Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Editor loop idle for 30ms in profiler?

Discussion in 'Data Oriented Technology Stack' started by martygrof3708, Apr 1, 2020.

  1. martygrof3708

    martygrof3708

    Joined:
    Dec 2, 2018
    Posts:
    200
    For some reason my game slows down like this when I schedule this job.
    Code (CSharp):
    1.     [BurstCompile] private struct MovementJob : IJobForEachWithEntity<PathIndex , PlatoonReference , Translation>
    2.     {
    3.         [ReadOnly] public float dt;
    4.         [ReadOnly] public BufferFromEntity<PathPosition> pathPositionBufferFromEntity;
    5.  
    6.         public void Execute( Entity entity , int index , ref PathIndex pathIndex , ref PlatoonReference reference , ref Translation translation )
    7.         {
    8.             if ( pathIndex.value >= 0 )
    9.             {
    10.                 DynamicBuffer<PathPosition> pathPositionBuffer = pathPositionBufferFromEntity[ reference.entity ];
    11.  
    12.                 float3 pathPosition = new float3(
    13.                     pathPositionBuffer[ pathIndex.value ].position.x ,
    14.                     translation.Value.y ,
    15.                     pathPositionBuffer[ pathIndex.value ].position.y );
    16.                 float distance = math.distance(
    17.                     pathPosition , translation.Value );
    18.                 float3 direction = math.normalize(
    19.                     pathPosition - translation.Value );
    20.  
    21.                 int branch = math.select( 0 , 1 , math.abs( direction.x ) <= 1 );
    22.                 float3 value = new float3(
    23.                     direction.x * 30f * dt ,
    24.                     0 ,
    25.                     direction.z * 30f * dt );
    26.  
    27.                 translation.Value += value * branch;
    28.  
    29.                 branch = math.select( 0 , 1 , distance <= 0.3f );
    30.                 pathIndex.value -= branch;
    31.             }
    32.         }
    33.     }
     

    Attached Files:

  2. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,106
    Show profiler hierarchy. Which count of entities it processing? Editor loop can idling because of waiting jobs chain completion I guess or waiting GPU. Anyway need to see profiler hierarchy.
     
  3. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    971
    To see what's happening in the EditorLoop, switch the Profiler target from Playmode to Editor. Also, if it is an issue of the main thread waiting for some job threads to finish, that might be more visible in Timeline view, so also check in there what the other threads are doing while the editor is slowing down.
     
    martygrof3708 likes this.
unityunity