Global/Per-Prefab Query Options
Whenever Bolt attaches a prefab (either due to instantiation on the client/server or a rescope on the client), it needs to query for three components: IEntityBehaviour
, IPriorityCalculator
, and IEntityReplicationFilter
. IEntityBehaviour
is familiar to most users of Bolt as this is what EntityBehaviour<TState>
implements. The other two are described in the documentation and rarely used by users.
Bolt allows multiples of each to exist. By default Bolt will perform a GetComponentsInChildren<T>
on your entity for each of these types to find them during Attach()
. Since this has to walk the entity’s children it is not necessarily the most performant option and it allocates some memory as well.
You can change the query behaviour globally for each of these interfaces in Bolt Settings, to either none
, getComponent()
, getComponents()
, and getComponentsInChildren()
. In addition, if you wish to override a prefab’s setting so that it is different than the global setting, you can do it in the entity’s setting on the prefab (the prefab will default to UseGlobal
).
For most users of Bolt, IEntityBehaviour
should be GetComponent()
as they will have one IEntityBehaviour
implemented class. IPriorityCalculator
and IEntityReplicationFilter
should be none as users usually don’t implement these (if you do, choose the appropriate setting for your scenario which is probably GetComponent).