Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

`EntityQuery` cannot be used in `ISharedComponentData`?

Discussion in 'Entity Component System' started by quabug, Mar 20, 2020.

  1. quabug

    quabug

    Joined:
    Jul 18, 2015
    Posts:
    66
    Unity 2019.3.3
    Entities 0.8.0-preview.8

    Code (CSharp):
    1.     public struct SharedEntityQuery : ISharedComponentData
    2.     {
    3.         public EntityQuery EntityQuery;
    4.     }
    5.    
    This code makes unity player throw exceptions on standalone build of both Windows and Mac.
    But works in Editor player.

    Code (CSharp):
    1. ReflectionTypeLoadException: Exception of type 'System.Reflection.ReflectionTypeLoadException' was thrown.
    2.   at (wrapper managed-to-native) System.Reflection.Assembly.GetTypes(System.Reflection.Assembly,bool)
    3.   at System.Reflection.Assembly.GetTypes () [0x00000] in <c79628fadf574d3a8feae0871fad28ef>:0
    4.   at Unity.Entities.TypeManager.InitializeAllComponentTypes () [0x00123] in G:\proj\entities-bt-unity\Library\PackageCache\com.unity.entities@0.8.0-preview.8\Unity.Entities\Types\TypeManager.cs:934
    5.   at Unity.Entities.TypeManager.Initialize () [0x00105] in G:\proj\entities-bt-unity\Library\PackageCache\com.unity.entities@0.8.0-preview.8\Unity.Entities\Types\TypeManager.cs:460
    6.   at Unity.Entities.EntityManager..ctor (Unity.Entities.World world) [0x00008] in G:\proj\entities-bt-unity\Library\PackageCache\com.unity.entities@0.8.0-preview.8\Unity.Entities\EntityManager.cs:162
    7.   at Unity.Entities.World..ctor (System.String name, Unity.Entities.WorldFlags flags) [0x00061] in G:\proj\entities-bt-unity\Library\PackageCache\com.unity.entities@0.8.0-preview.8\Unity.Entities\World.cs:188
    8.   at Unity.Entities.DefaultWorldInitialization.Initialize (System.String defaultWorldName, System.Boolean editorWorld) [0x0002c] in G:\proj\entities-bt-unity\Library\PackageCache\com.unity.entities@0.8.0-preview.8\Unity.Entities.Hybrid\Injection\DefaultWorldInitialization.cs:114
    9.   at Unity.Entities.AutomaticWorldBootstrap.Initialize () [0x00001] in G:\proj\entities-bt-unity\Library\PackageCache\com.unity.entities@0.8.0-preview.8\Unity.Entities.Hybrid\Injection\AutomaticWorldBootstrap.cs:15
    10. (Filename: <c79628fadf574d3a8feae0871fad28ef> Line: 0)
    11.  
    12. ArgumentException: Unknown Type:`Unity.Entities.CompanionLink` All ComponentType must be known at compile time. For generic components, each concrete type must be registered with [RegisterGenericComponentType].
    13.   at Unity.Entities.TypeManager.GetTypeIndex (System.Type type) [0x00025] in G:\proj\entities-bt-unity\Library\PackageCache\com.unity.entities@0.8.0-preview.8\Unity.Entities\Types\TypeManager.cs:590
    14.   at Unity.Entities.AttachToEntityClonerInjection.Initialize () [0x00007] in G:\proj\entities-bt-unity\Library\PackageCache\com.unity.entities@0.8.0-preview.8\Unity.Entities.Hybrid\Injection\CompanionGameObject.cs:28
    15.   at Unity.Entities.AttachToEntityClonerInjection..cctor () [0x00001] in G:\proj\entities-bt-unity\Library\PackageCache\com.unity.entities@0.8.0-preview.8\Unity.Entities.Hybrid\Injection\CompanionGameObject.cs:21
    16. Rethrow as TypeInitializationException: The type initializer for 'Unity.Entities.AttachToEntityClonerInjection' threw an exception.