protected override JobHandle OnUpdate(JobHandle jobHandle) { if (entityQuery.IsEmptyIgnoreFilter) { return(jobHandle); } var chunkCount = entityQuery.CalculateChunkCount(); using (var meshRenderIndexes = new NativeArray <int>(chunkCount, Allocator.TempJob, NativeArrayOptions.UninitializedMemory)) using (var sortedSharedIndexes = new NativeArraySharedValues <int>(meshRenderIndexes, Allocator.TempJob)) { Profiler.BeginSample("Sort Shared RenderMesh"); { jobHandle = new FillSharedIndexInChunkJob <RenderMesh> { sharedType = GetArchetypeChunkSharedComponentType <RenderMesh>(), sharedIndexesInChunk = meshRenderIndexes }.Schedule(entityQuery, jobHandle); jobHandle = sortedSharedIndexes.Schedule(jobHandle); jobHandle.Complete(); } Profiler.EndSample(); Profiler.BeginSample("Prepare & Set FameOffset"); { var sharedRenderCount = sortedSharedIndexes.SharedValueCount; for (var i = 0; i < sharedRenderCount; ++i) { var sharedValueIndices = sortedSharedIndexes.GetSharedValueIndicesBySharedIndex(i); if (sharedValueIndices.Length == 0) { continue; } var renderMesh = EntityManager.GetSharedComponentData <RenderMesh>(meshRenderIndexes[sharedValueIndices[0]]); var renderMeshKey = AnimUtils.ToHash128(ref renderMesh); if (!properties.ContainsKey(renderMeshKey)) { properties.Add(renderMeshKey, new PropertyData(1024)); } var arrayData = properties[renderMeshKey]; Profiler.BeginSample("Set FameOffset"); arrayData.SetData(renderMesh.material); Profiler.EndSample(); Profiler.BeginSample("Prepare FameOffset"); entityQuery.SetSharedComponentFilter(renderMesh); jobHandle = arrayData.Schedule(entityQuery, this, jobHandle); entityQuery.ResetFilter(); Profiler.EndSample(); } } Profiler.EndSample(); } return(jobHandle); }
protected override void OnUpdate() { Entities.ForEach((Animator animator) => AnimUtils.ConvertAnimation(DstEntityManager, this, animator)); }