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

Feedback ToEntityArrayAsync and EntityQueryDesc Any?

Discussion in 'Entity Component System' started by Guedez, Jun 12, 2021.

  1. Guedez

    Guedez

    Joined:
    Jun 1, 2012
    Posts:
    827
    When creating an EntityQuery with an array of types using the EntityQueryDesc parameter, and filling said list in the Any field of EntityQueryDesc, I can get a list of Entities that match the querry, yet it seems I can't ToEntityArrayAsync on those? I get that there is an ambiguity with what to do with the entities that don't have said values, but I wish I could have the ToEntityArrayAsync fill missing values with "default" rather than throwing an error. Is there an alternative?
    EntityQuery creation:
    EntityQuery = GetEntityQuery(new EntityQueryDesc() { Any = Types.Cast(T => new ComponentType(T, ComponentType.AccessMode.ReadOnly)).ToArray() });


    Getting the values:
    return EntityQuery.ToComponentDataArrayAsync<T>(Allocator.TempJob, out Stage0Dependency).Reinterpret<bool>();

    OBS: Can I reinterpret an ToComponentDataArrayAsync? Couldn't test yet since the method throws
    Trying to get iterator for TypeGoesHere but the required component type was not declared in the EntityQuery
    to begin with.


    EDIT: Solved by doing something completely different, refer to https://forum.unity.com/threads/organizing-data.1124662/#post-7232879
     
    Last edited: Jun 12, 2021