Query
Query creation
public static void EntityQueries()
{
var store = new EntityStore();
store.CreateEntity(new EntityName("entity-1"));
store.CreateEntity(new EntityName("entity-2"), Tags.Get<MyTag1>());
store.CreateEntity(new EntityName("entity-3"), Tags.Get<MyTag1, MyTag2>());
// --- query components
var queryNames = store.Query<EntityName>();
queryNames.ForEachEntity((ref EntityName name, Entity entity) => {
// ... 3 matches
});
// --- query components with tags
var namesWithTags = store.Query<EntityName>().AllTags(Tags.Get<MyTag1, MyTag2>());
namesWithTags.ForEachEntity((ref EntityName name, Entity entity) => {
// ... 1 match
});
// --- use query.Entities in case an iteration requires no component access
foreach (var entity in queryNames.Entities) {
// ... 3 matches
}
}Query Filter
StructuralChangeException
Example: Query<>()
Example: QuerySystem<>
Projects prior v3.1.0
CommandBuffer
Last updated