This repository has been archived by the owner on Aug 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
ComponentGroup
Spy-Shifty edited this page Jan 8, 2018
·
15 revisions
Represents a group of entities with a specific set of components. Components are held in type specific lists. An index in the component lists belongs to the same entity. Groups are updated automatically. ComponentGroups are used internally in ComponentSystems in combination with the Tuple attribute.
using UnityEngine;
using ECS;
public class MySystem : ComponentSystem {
ComponentArray<TransformComponent> transformArray;
ComponentArray<AnimatorComponent> animatorArray;
public override void OnStart(){
// create a new Component group which contains entities with both, TransformComponent and AnimatorComponent
var group = new ComponentGroup(EntityManager, typeof(TransformComponent), typeof(AnimatorComponent));
// access ComponentArrays from the group
transformArray = group.GetComponent<TransformComponent>();
animatorArray = group.GetComponent<AnimatorComponent>();
}
public override void OnUpdate(){
// iterate through the components of the group
for (int i = 0; i < transformArray.Length; i++) {
// both components belongs to the same entity
Transform transform = transformArray[i].transform;
Animator animator = animatorArray[i].animator;
}
}
}
Command | Description |
---|---|
ComponentGroup | Creates a new group of given component types |
Command | Description |
---|---|
GetComponent | Returns the ComponentArry of the specific component type |
Will be fired if an Entity was added to the group
Command | Description |
---|---|
SubscribeOnEntityAdded | Subscribe eventlistener to OnEntityAdded event |
UnsubscribeOnEntityAdded | Unsubscribe eventlistener from OnEntityAdded event |
Will be fired if an Entity will be removed from the group
Command | Description |
---|---|
SubscribeOnEntityRemoving | Subscribe eventlistener to OnEntityRemoving event |
UnsubscribeOnEntityRemoving | Unsubscribe eventlistener from OnEntityRemoving event |
Will be fired if an Entity was removed from the group
Command | Description |
---|---|
SubscribeOnEntityRemoved | Subscribe eventlistener to OnEntityRemoved event |
UnsubscribeOnEntityRemoved | Unsubscribe eventlistener from OnEntityRemoved event |