Search Unity

[SOLVED] Systems that access ComponentObject, Translation, and Rotation not updating in IL2CPP

Discussion in 'Entity Component System' started by desertGhost_, Aug 26, 2019.

  1. desertGhost_

    desertGhost_

    Joined:
    Apr 12, 2018
    Posts:
    260
    Edit: I was missing two assemblies in my link file

    Note: All other systems run properly. Here is the link file I am using:

    Code (CSharp):
    1. <linker>
    2.        <assembly fullname="Unity.Entities" preserve="all"/>
    3.        <assembly fullname="Unity.Entities.Hybrid" preserve="all"/>
    4.        <assembly fullname="Unity.Transforms" preserve="all"/>
    5.        <assembly fullname="Unity.Collections" preserve="all"/>
    6.        <assembly fullname="Unity.Jobs" preserve="all"/>
    7.        <assembly fullname="Unity.Mathematics" preserve ="all"/>
    8. </linker>
    I'm seeing a weird bug where systems that access a ComponentObject, Translation, and Rotations on an entity are not working properly in builds with IL2CPP built in 2019.2.2f1. All of the affected systems run properly in the editor and mono builds. For instance a system with this code does not update at all (like the query is empty):

    Code (CSharp):
    1.  
    2.                 Entities.WithAll<SyncTransformToEntityTag>()
    3.                 .ForEach((Transform transform,
    4.                                 ref Translation translation, ref Rotation rotation) =>
    5.                 {
    6.                     transform.position = translation.Value;
    7.                     transform.rotation = rotation.Value;
    8.                 });
    Changing the code to

    Code (CSharp):
    1.  
    2.                 Entities.WithAll<SyncTransformToEntityTag>()
    3.                 .ForEach((Entity entity, Transform transform) =>
    4.                 {
    5.                     if (EntityManager.HasComponent<Translation>(entity))
    6.                     {
    7.                         Debug.Log("Get position");
    8.                         transform.position = EntityManager.GetComponentData<Translation>(entity).Value;
    9.                     }
    10.  
    11.                     if (EntityManager.HasComponent<Rotation>(entity))
    12.                     {
    13.                         Debug.Log("Get Rotation");
    14.                         transform.rotation = EntityManager.GetComponentData<Rotation>(entity).Value;
    15.                     }
    16.                 });
    shows the system running in the profiler in IL2CPP builds, but the debug statements are not logged and the transform is not changed. This code runs properly in the editor and in mono builds. This happens with systems that use other component objects, like a character controller, and a translation, and rotation.

    In any case the entities are created with the ConvertToEntity script with the Convert and Inject GameObject mode.

    Any ideas?
     
    Last edited: Aug 26, 2019
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,759
    You're not including your own code in the link xml
     
  3. desertGhost_

    desertGhost_

    Joined:
    Apr 12, 2018
    Posts:
    260
    I have it in a separate link file:
    Code (csharp):
    1. <linker>
    2.        <assembly fullname="CopernicusCore" preserve="all"/>
    3. </linker>
    4.  
    5.  
    Edit: I have tried using a single link file and multiple link files.
     
    Last edited: Aug 26, 2019
  4. desertGhost_

    desertGhost_

    Joined:
    Apr 12, 2018
    Posts:
    260
    I have resolved the issue by adding Unity.Transforms.Hybrid and Unity.Rendering.Hybrid to the link file.

    Thanks.
     
  5. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,759
    Ah! was just about to post that. Glad that works.

    Here's my full link.xml that seems to work for anyone else who stumbles across this

    Code (CSharp):
    1. <linker>
    2.    <assembly fullname="Unity.Collections" preserve="all" />
    3.    <assembly fullname="Unity.Entities" preserve="all" />
    4.    <assembly fullname="Unity.Entities.Hybrid" preserve="all" />
    5.    <assembly fullname="Unity.Entities.Properties" preserve="all" />
    6.    <assembly fullname="Unity.Entities.StaticTypeRegistry" preserve="all" />
    7.    <assembly fullname="Unity.Transforms" preserve="all" />
    8.    <assembly fullname="Unity.Transforms.Hybrid" preserve="all" />
    9.    <assembly fullname="Unity.Jobs" preserve="all" />
    10.    <assembly fullname="Unity.ZeroPlayer" preserve="all" />
    11.    <assembly fullname="Unity.ZeroJobs" preserve="all" />
    12.    <assembly fullname="Unity.Rendering.Hybrid" preserve="all" />
    13.    <assembly fullname="Unity.Mathematics" preserve="all" />
    14.    <assembly fullname="Unity.Properties" preserve="all" />
    15.    <assembly fullname="Unity.Burst" preserve="all" />
    16.    <assembly fullname="Unity.Physics" preserve="all" />
    17.    <assembly fullname="Unity.Physics.Hybrid" preserve="all" />
    18. </linker>
     
    desertGhost_ likes this.