Do I need to call some function to tell the engine that I want to destroy the entity? Or just remove it from scene and wait for GC?
Entity.Scene.Entities.Remove(yourEntity);
yourEntity.Dispose();
1 Like
It works fine, Thank you!
Actually, I find it will also be GC if just remove from Scene without calling Dispose.
1 Like
I’m glad that you’d found it helpful!
C ya!
Yes, GC will eventually collect objects even if you don’t Dispose them, but the timing of the GC getting around to it is unknown.
If the object holds resources (like memory or locks), they can hold onto them much longer than you want if you wait for GC. That’s why Dispose is a good habit if you are sure the object is no longer used, because it frees resoures immediately.
OK, Thanks for the answer!