Is there a way to return all the EventInstance attached to a GameObject by giving it a GameObject?
Or do I need to manually record the relationships between GameObjects and EventInstance myself?
Hi,
For EventInstances that are attached to GameObjects via RuntimeManager functions such as RuntimeManager.attachInstanceToGameObject()
, there’s currently no way to return all EventInstances attached to a given GameObject. If you want to keep track of the EventInstances attached to a GameObject, you will need to store references to them yourself.
If possible, can I get you to provide some more context on what exactly you’re trying to do? I might be able to provide some direction or assistance.
Thank you for your reply.
The situation I want to deal with is that when I create a GameObject, I may attach multiple EventInstances to it, and when I destroy the GameObject, I want to be able to destroy all of them at the same time, or maybe the GameObject doesn’t need to be destroyed, but I need to stop all the EventInstance attached on it.
So I think maybe I need to keep track of how each EventInstance relates to the GameObject.
In that case, yes, you’ll need to keep track of the EventInstances yourself.
If the EventInstances are being created from and attached to the same GameObject, then it should just be a matter of storing the instances in a List. If the EventInstances are being created from and attached to different GameObjects, it will be a little more complex since you’ll need to track both the EventInstance and the GameObject it’s attached to - I would recommended taking a look at how RuntimeManager
handles this with the private class AttachedInstance
and the attachedInstances
List.