Working as intended
**UPDATE**
When the actor is pulled from content browser to scene, a "ghost" object is created even if the actor is still being "held". Dragging the actor back and forth into the editor viewport will create multiple of the "ghosts". When the actor is released another object is created. When the actor in the viewport is deleted the destructor is called for each of the "ghost" objects that were created but not for the object that was actually deleted.
-------------------------------------------------------------------------------------------
If multiple instances of a single class are placed in a level, deleting any one instance will call the class destructor once for each instance present in the scene. Any current instance will then not have the destructor called when removed (this includes using undo and deleting the original instance again).
1. Open UE4 Editor (any project)
2. Add code to project based on Actor (NewActor)
3. In the header file add the following to create a destructor:
~NewActor();
4. In the source file add the following:
AMyActor::~AMyActor()
{
UE_LOG(LogTemp, Warning, TEXT("Destructor Test"));
}
5. Compile
6. Add multiple copies (6) of NewActor(Instance) to the scene
7. Go to Window->Developer Tools->Output Logs to show output logs
8. Select one instance of NewActor and press the delete key
Result:
Output Logs show the "Destructor Test" text 6 times.
Why does the REMOVE method of map container remove elements have memory leaks?
How do I set a material as a post-processing material?
How does TextureRenderTarget2D get TArray<uint8> type data?
What is the cause of the packaging error falling back to 'GameUserSettings' in ue5?
How to delete some elements correctly when deleting an array loop?
How does TArray loop correctly remove elements in blueprints?
How to implement springarm components to scale according to mouse position in spawn?
Head over to the existing Questions & Answers thread and let us know what's up.