I’m having a problem where I need to keep a list of certain GameObjects in an object with their id and reference to the GameObject which I call entity in code. I want to use this object to get the specific entities when I want to run some action on them from my React ui code.
This means that I need to make sure that my entitiesStore
is up to date with existing GameObjects in the game. While it is easy enough to add them to the store for example in constructor of the entity, I’m not sure how to remove them from my store when it is required. Is there any way to call some code before destroy()
in the GameObjects?
I’m aware I could use this.children.getByName('string-name');
etc. to get GameObject by its name but I need to fetch objects in code where the current Scene is not readily available or when I can’t be sure which Scene contains the wanted GameObject.
As a bonus, is there property in GameObject which I could check to know if the GameObject has been destroyed?