Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VisualDebugger bug when components are added on entity creation #87

Closed
LinusVanElswijk opened this issue Mar 24, 2016 · 3 comments
Closed
Labels

Comments

@LinusVanElswijk
Copy link

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
  }
  ...
}
@LinusVanElswijk
Copy link
Author

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.

@sschmid
Copy link
Owner

sschmid commented Mar 24, 2016

Oh, ok, Thanks, I'll take a look

@sschmid
Copy link
Owner

sschmid commented Mar 25, 2016

Hey! It's fixed now, thanks for pointing it out. Will be in the next release! Happy coding :)

@sschmid sschmid closed this as completed Mar 25, 2016
@sschmid sschmid added this to Entitas Jul 2, 2023
@github-project-automation github-project-automation bot moved this to Todo in Entitas Jul 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

No branches or pull requests

2 participants