Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[BUG] Error while post processing the assembly - 0.3.0-preview.4

Discussion in 'Entity Component System' started by frimarichard, Dec 4, 2019.

  1. frimarichard

    frimarichard

    Joined:
    Jul 24, 2017
    Posts:
    31
    After upgrading from 0.1.1 to 0.3.0-preview.4 and converting my old systems, I'm seeing this error:

    while using this code:

    Code (CSharp):
    1. internal abstract class AbstractRemoveTagJobSystem<TData, TBuffer> : JobComponentSystem
    2.     where TData : struct, IComponentData where TBuffer : EntityCommandBufferSystem
    3. {
    4.     private TBuffer m_CommandBuffer;
    5.  
    6.     protected override void OnCreate()
    7.     {
    8.         m_CommandBuffer = World.GetOrCreateSystem<TBuffer>();
    9.     }
    10.  
    11.     protected override JobHandle OnUpdate(JobHandle inputDeps)
    12.     {
    13.         var commandBuffer = m_CommandBuffer.CreateCommandBuffer().ToConcurrent();
    14.  
    15.         inputDeps = Entities
    16.             .WithAll<TData>()
    17.             .ForEach((Entity entity, int entityInQueryIndex) =>
    18.             {
    19.                 commandBuffer.RemoveComponent<TData>(entityInQueryIndex, entity);
    20.             })
    21.             .Schedule(inputDeps);
    22.  
    23.         m_CommandBuffer.AddJobHandleForProducer(inputDeps);
    24.  
    25.         return inputDeps;
    26.     }
    27. }
    If I comment out the WithAll<TData> and the RemoveComponent<TData>, the compilation exception no longer occurs.

    It is the same whether or not the class is used by a concrete implementation.
     
    Last edited: Dec 4, 2019
  2. frimarichard

    frimarichard

    Joined:
    Jul 24, 2017
    Posts:
    31
    I'm also seeing a similiar error:

    while using this code:

    Code (CSharp):
    1. internal class BulletCollisionSystem : JobComponentSystem
    2. {
    3.     private EntityCommandBufferSystem m_CommandBufferSystem;
    4.  
    5.     protected override void OnCreate()
    6.     {
    7.         m_CommandBufferSystem = World.GetOrCreateSystem<EndSimulationEntityCommandBufferSystem>();
    8.     }
    9.  
    10.     protected override JobHandle OnUpdate(JobHandle inputDeps)
    11.     {
    12.         var commandBuffer = m_CommandBufferSystem.CreateCommandBuffer();
    13.  
    14.         Entities
    15.             .WithAll<IsBulletTag>()
    16.             .ForEach((Entity entity, DynamicBuffer<NewCollisionElementData> collisionBuffer) =>
    17.             {
    18.                 for (int i = 0; i < collisionBuffer.Length; i++)
    19.                 {
    20.                     var collisionEntity = collisionBuffer[i].Entity;
    21.  
    22.                     if (EntityManager.HasComponent<IsTerrainTag>(collisionEntity))
    23.                     {
    24.                         DestroyUtility.MarkForDestroy(entity, commandBuffer);
    25.                         continue;
    26.                     }
    27.                 }
    28.             })
    29.             .WithoutBurst()
    30.             .Run();
    31.  
    32.         return inputDeps;
    33.     }
    34. }
    The error disappears if DestroyUtility.MarkForDestroy() is removed.
    Note that this occurs even if DestroyUtility.MarkForDestroy() is an empty function.
     
  3. frimarichard

    frimarichard

    Joined:
    Jul 24, 2017
    Posts:
    31
    Furthermore (this is fun):

    Code (CSharp):
    1.     protected override JobHandle OnUpdate(JobHandle inputDeps)
    2.     {
    3.         var commandBuffer = m_CommandBufferSystem.CreateCommandBuffer();
    4.         var terrainCDFE = GetComponentDataFromEntity<IsTerrainTag>(true);
    5.  
    6.         Entities
    7.             .WithAll<IsBulletTag>()
    8.             .WithReadOnly(terrainCDFE)
    9.             .ForEach((Entity entity, DynamicBuffer<NewCollisionElementData> collisionBuffer) =>
    10.             {
    11.                 var array = collisionBuffer.ToNativeArray(Allocator.Temp);
    12.                 for (int i = 0; i < array.Length; i++)
    13.                 {
    14.                     //if (terrainCDFE.Exists(array[i].Entity))
    15.                     if (EntityManager.HasComponent<IsTerrainTag>(array[i].Entity))
    16.                     {
    17.                         //DestroyUtility.MarkForDestroy(entity, commandBuffer);
    18.                         continue;
    19.                     }
    20.                 }
    21.             })
    22.             .WithoutBurst()
    23.             .Run();
    24.  
    25.         return inputDeps;
    26.     }
    This code compiles, but using terrainCDFE instead of EntityManager causes the same exception as above.
     
  4. Roycon

    Roycon

    Joined:
    Jul 10, 2012
    Posts:
    50
    I get this too, not sure if its 100% the same issue, as mine started when I introduced assembly definitions to my project

    My workaround is to go to: Unity.Entities.CodeGen.CecilExtentionsMethods, Line 142 and change it to
    Code (CSharp):
    1. var baseTypeRef = arg?.BaseType;
    The added null check caused that method to return false and whatever magic was calling it was happy