From 409b17df2d1e0febfec3ec0c2132b7c8938a430e Mon Sep 17 00:00:00 2001 From: Ruan Lucas <79365912+RuanLucasGD@users.noreply.github.com> Date: Sun, 24 Sep 2023 11:28:07 -0400 Subject: [PATCH 1/2] Remake --- Source/Engine/Level/Actor.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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++) { From ba204029009c04f31f862975e8c31d5d2a77ec5e Mon Sep 17 00:00:00 2001 From: Ruan Lucas <79365912+RuanLucasGD@users.noreply.github.com> Date: Thu, 28 Sep 2023 19:05:26 -0400 Subject: [PATCH 2/2] Change OnDestroy order --- Source/Engine/Level/Actor.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Source/Engine/Level/Actor.cpp b/Source/Engine/Level/Actor.cpp index 5d4cd9495..f89083177 100644 --- a/Source/Engine/Level/Actor.cpp +++ b/Source/Engine/Level/Actor.cpp @@ -877,6 +877,12 @@ void Actor::EndPlay() #endif // Fire event for scripting + if (IsActiveInHierarchy() && GetScene()) + { + ASSERT(GetScene()); + OnDisable(); + } + for (auto* script : Scripts) { CHECK_EXECUTE_IN_EDITOR @@ -885,13 +891,6 @@ void Actor::EndPlay() } } - // Fire event for scripting - if (IsActiveInHierarchy() && GetScene()) - { - ASSERT(GetScene()); - OnDisable(); - } - OnEndPlay(); // Clear flag