Hi all.
I have a component that in edit and play mode creates data using a NativeArray and jobs in both modes.
I create it on Start() or whenever I click the editor and it hasn’t been initialized. That way it is created in both editor and play mode.
I dispose all in OnDestroy. In editor I never do, it’s not cheap to destroy and create it all the time, the instance is always there.
If I ever selected the object after having played, (and the array is created in edit mode), whenever I hit play, OnDisable is called for the editor (if it was selected), but either way I get a LEAK . the rest of the process continues. (A Native Collection has not been disposed, resulting in a memory leak. It was allocated)
It is obvious that I’m missing an event right before Play that tells me to dispose all objects created in edit mode that will be created again on play… but I don’t know if there’s any event or any way to do this.
Thanks