That may work… but it sort of ignores the real issue: I don’t need or want the particle effect anymore, so destroying it makes sense and this code should destroy the gameObject, but does not.
Im reluctant to go the “disable” route, as I could land up with hundreds of these “disabled effects” which really aren’t needed anymore.
means you don’t enjoy optimizing, pooling and is an incredibly efficient way to handle objects in OOP, what your saying is you don’t want to pool anything.
Try using DestroyImmediate( object );
or instead of casting to GameObject, try UnityEditor.Object. However its weird to see it not working. I know calling Destroy doesn’t necessarily mean its out of memory with managed code, but being that its a unity object I’m pretty sure those aren’t garbage collected anyway.
I guess I could try pooling, but it seems unlikely to make any real difference: it’s a tiny object to instantiate and I can’t believe that instantiating/destroying it would be significantly worse performance-wise than using an object pool. I haven’t tested pooling here, so I’m just guessing about the lack of significant performance difference.
And yes, it makes it through the coroutine. I’ve only shown the code related to the attempt to destroy it, but everything else works exactly as expected.
DestoryImmediate() makes no difference, neither does instantiating as an Object instead of a GameObject. It’s very puzzling.