Struct TraitQuery
Query object
Namespace: Unity.Semantic.Traits.Queries
Syntax
public struct TraitQuery : IEnumerable<Entity>, IEnumerable, IDisposable
Constructors
TraitQuery(EntityManager)
Create a new TraitQuery, which caches results, and must be disposed after its use
Declaration
public TraitQuery(EntityManager entityManager)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityManager | entityManager | The entity manager that will be used for entity queries |
Properties
EntityCount
Count of entities resulting from the trait query
Declaration
public int EntityCount { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
Item[Int32]
Access the element at the specified index from the trait query results
Declaration
public Entity this[int index] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index | Index of the element from the results |
Property Value
| Type | Description |
|---|---|
| Entity |
Methods
Clone()
Clone an existing trait query (in order to preserve the original)
Declaration
public TraitQuery Clone()
Returns
| Type | Description |
|---|---|
| TraitQuery | A copy of this trait query with a new cache for query results (that must be disposed) |
Dispose()
Declaration
public void Dispose()
GetEnumerator()
Return the query result or perform the query if not completed
Declaration
public IEnumerator<Entity> GetEnumerator()
Returns
| Type | Description |
|---|---|
| IEnumerator<Entity> | Query result |
Or()
Add a new conditional group to the query with an OR operator
Declaration
public TraitQuery Or()
Returns
| Type | Description |
|---|---|
| TraitQuery | An updated trait query with a new conditional group |
Reset()
Reset the current cached results of the query, so that it can be re-executed
Declaration
public void Reset()
WithFilter<T>(T)
Constrain the trait query further with a filter (use Clone() to preserve original)
Declaration
public TraitQuery WithFilter<T>(T filter)
where T : IQueryFilter
Parameters
| Type | Name | Description |
|---|---|---|
| T | filter | Filter to add to the trait query |
Returns
| Type | Description |
|---|---|
| TraitQuery | An updated trait query w/ the filter |
Type Parameters
| Name | Description |
|---|---|
| T | A filter type that implements IQueryFilter |