► React to Editor Destroying/Deleting an Actor

This seemed to work as expected for me. When I create my child actors I make sure to set their owner as the region so when the region is ::Destroyed() it will go through all world actors that contain the same owner and call their ->Destroy() method. Here is the code to get all child room actors w/the region as the owner:

TArray<ARoom*> ARegion::GetRoomActors()
{
	// get all child components
	TArray<ARoom*> result;
	for (TActorIterator<ARoom> room(GetWorld()); room; ++room)
	{
		if (!room || !room->IsValidLowLevel())
			continue;

		if (room->GetOwner() == this)
			result.Add(*room);
	}
	return result;
}

So I avoid storing a child actor pointer array but I have to pull it from the world when I need it. I guess that is the only difference.

You know it would be much better if we can tell if the user is just dragging an actor into the scene so we can avoid any unnecessary construction. Is this possible?

You know it would be much better if we can tell if the user is just dragging an actor into the scene so we can avoid any unnecessary construction. Is this possible? I added my code below but wanted to raise the question.

Hey -

I just want to confirm that the code you posted does in fact allow you to delete the parent actor which will automatically delete the child actors that the parent generated at creation? As for dragging into the scene creating a temporary actor, this is the expected behavior. When destroying the actor it is only destroyed via garbage collection when the engine does that operation. At that point any unrefrenced temporary actors would be destroyed. If your instances are still valid then they are not deleted.