Reputation: 597
I got this error while trying vectors of unions
error: Vectors of unions are not yet supported in all the specified
programming languages.
Clearly flatbuffers doesn't support vectors of unions. So i need another data type to solve my problem. Here's my case:
Using model Entity Component System (ECS), i have 3 entities and 3 components, here's the structure
EntityA EntityB EntityC
component1 component1 component3
component3 component2
If i can use vectors of unions the schema look like this
union Components { Component1, Component2, Component3 }
table Update {
component:[Components];
}
Where Component[N] are tables. Actually i have a solution without vectors of unions
table Update {
component1:[Component1];
component2:[Component2];
component3:[Component3];
}
But when list of component increase it's becoming unmanageable.
I'm sorry, i'm using ECS and this is for game development actually. But it's not about the game, so i think this is the right place for asking this kind of problem.
How to solve this without Vectors of unions and better than above solution?
Upvotes: 2
Views: 2835
Reputation: 6074
Yes, vectors of unions is a new feature (added just a few weeks ago) that so far is only available in C++.
The traditional way is to create a table Component { c:Components; }
to wrap the union value, then to make a [Component]
out of them.
Using multiple vectors may indeed become inefficient if the number of components is high.
Upvotes: 4