I have an entity that was part of the map on start, which has the GameObjectEntity ScriptBehaviour component on it as well as my own ECS components.
However when I try to delete it with EntityManager.DestroyEntity, I get an error:
Can't remove GameObjectEntity (Script) because ECSCharacterController (Script), Buildable (Script), Health (Script), Owner (Script), Selectable (Script), Moveable (Script), Rotatable (Script), AIModeData (Script), Sellable (Script), Unit (Script), Weapon (Script), ECSTransform (Script), ECSColliders (Script) depends on it
The above scripts I have assigned via the inspector. All of mine are ComponentDataWrappers, except ECSCharacterController, which is ComponentWrapper.
The Transform component seems to have been removed, as I later get a "The given key was not present in the dictionary" error regarding ECS.TransformComponent.
The Unity GameObject also remains in the world.
I don't recall exactly which commit this started with, but I don't believe this happened as of commit on Dec 28th.
Here's the code that deletes it:
` public class HealthSystem : ComponentSystem
{
[InjectDependency]
private UnityEntityManager entityManager = null;
// this will inject all entities with components of type MyComponent
// if you define multiple ComponentArrays with the [InjectTuple] tag
// you will only receive those entities with both Components
[InjectTuple]
ComponentArray<HealthComponent> healthComponentArray;
// Use this for standard unity update function
public override void OnUpdate()
{
for (int i = 0; i < healthComponentArray.Length; i++)
{
// If health is at or below 0, destroy entity
if (healthComponentArray[i].health <= 0)
entityManager.DestroyEntity(healthComponentArray.GetEntity(i));
// Make sure health is no higher than max health
else if (healthComponentArray[i].health > healthComponentArray[i].maxHealth)
entityManager.SetComponent(healthComponentArray.GetEntity(i), new HealthComponent() { health = healthComponentArray[i].maxHealth, maxHealth = healthComponentArray[i].maxHealth });
}
}
}
I have an entity that was part of the map on start, which has the GameObjectEntity ScriptBehaviour component on it as well as my own ECS components.
However when I try to delete it with EntityManager.DestroyEntity, I get an error:
The above scripts I have assigned via the inspector. All of mine are ComponentDataWrappers, except ECSCharacterController, which is ComponentWrapper. The Transform component seems to have been removed, as I later get a "The given key was not present in the dictionary" error regarding ECS.TransformComponent. The Unity GameObject also remains in the world.
I don't recall exactly which commit this started with, but I don't believe this happened as of commit on Dec 28th.
Here's the code that deletes it: ` public class HealthSystem : ComponentSystem { [InjectDependency] private UnityEntityManager entityManager = null;
`