How do you get around pooling objects that have OnDisable and OnEnable functionality? I’m using a bool to skip the first time the methods are called, but that seems very hacky and in scenerios where the pooler create objects on-demand, it will won’t work.
Is there any clean solutions to this problem? I wish there was a way to instantiate an inactive gameobject…
If you don’t want to use the OnDisable/Enable methods, why not make your own initialization/deinitialization methods and call those from the pooler as needed instead?
You enable then when they’re out of pool and disable when they’re sent back to pool.
In the first place, your OnEnable/OnDisable should be written in such way that they could be called multiple times, even if there’s no pool. I.e. “OnEnable, OnDisable, OnEnable, OnDisable, …”
I’m not clear on what the problem is. What are you trying to achieve that isn’t working as intended?
OnEnable/OnDisable are meant to be used for things that need to happen whenever a Component is enabled or disabled, which can happen multiple times in its lifecycle. Start/OnDestroy are meant to be used for once-off things at the start or end of the lifecycle. If neither of those fit then adding your own stuff called by your pool class is the way to go.