You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you add a component to an entity on an OnEntityCreated event, line 34 of the PoolObserverInspector will throw an exception whenever you use the CreateEntity button of the visual debugger.
At the time this line of code is executed, the name of GameObject that is associated is not yet updated to contain the added component, causing a failure on Object.FindObjectsOfType<EntityBehaviour>().Single(eb => eb.name == entity.ToString());.
The setup I use:
public class MySystem : IInitializeSystem {
...
public void Initialize() {
pool.OnEntityCreated += AddComponent;
}
//what I would like to do
public void AddComponent(Pool pool, Entity entity) {
entity.AddMyComponent(someValue);
}
//temporary fix: force the gameObject to update it's name
public void AddComponent(Pool pool, Entity entity) {
#if (UNITY_EDITOR)
var entityBehaviour = GameObject.FindObjectsOfType<EntityBehaviour>()
.Single(eb => eb.name == entity.ToString());
#endif
entity.AddMyComponent(someValue);
#if (UNITY_EDITOR)
entityBehaviour.gameObject.name = entity.ToString();
#endif
}
...
}
The text was updated successfully, but these errors were encountered:
A related issue: if you have multiple pools, then you can end up with multiple entities with the same name, which also causes an exception on the same line of code.
If you add a component to an entity on an
OnEntityCreated
event,line 34 of the PoolObserverInspector will throw an exception whenever you use the CreateEntity button of the visual debugger.
At the time this line of code is executed, the name of
GameObject
that is associated is not yet updated to contain the added component, causing a failure onObject.FindObjectsOfType<EntityBehaviour>().Single(eb => eb.name == entity.ToString());
.The setup I use:
The text was updated successfully, but these errors were encountered: