diff --git a/Source/Engine/Level/Actor.cpp b/Source/Engine/Level/Actor.cpp index 394d5c9dc..5d4cd9495 100644 --- a/Source/Engine/Level/Actor.cpp +++ b/Source/Engine/Level/Actor.cpp @@ -876,6 +876,15 @@ void Actor::EndPlay() CHECK(IsDuringPlay()); #endif + // Fire event for scripting + for (auto* script : Scripts) + { + CHECK_EXECUTE_IN_EDITOR + { + script->OnDestroy(); + } + } + // Fire event for scripting if (IsActiveInHierarchy() && GetScene()) { @@ -895,15 +904,6 @@ void Actor::EndPlay() Children[i]->EndPlay(); } - // Fire event for scripting - for (auto* script : Scripts) - { - CHECK_EXECUTE_IN_EDITOR - { - script->OnDestroy(); - } - } - // Inform attached scripts for (int32 i = 0; i < Scripts.Count(); i++) {