Merge branch 'Fix-Actor-OnDestroy' of https://github.com/RuanLucasGD/FlaxEngine into RuanLucasGD-Fix-Actor-OnDestroy

This commit is contained in:
Wojtek Figat
2023-10-08 16:41:40 +02:00

View File

@@ -883,6 +883,14 @@ void Actor::EndPlay()
OnDisable(); OnDisable();
} }
for (auto* script : Scripts)
{
CHECK_EXECUTE_IN_EDITOR
{
script->OnDestroy();
}
}
OnEndPlay(); OnEndPlay();
// Clear flag // Clear flag
@@ -895,15 +903,6 @@ void Actor::EndPlay()
Children[i]->EndPlay(); Children[i]->EndPlay();
} }
// Fire event for scripting
for (auto* script : Scripts)
{
CHECK_EXECUTE_IN_EDITOR
{
script->OnDestroy();
}
}
// Inform attached scripts // Inform attached scripts
for (int32 i = 0; i < Scripts.Count(); i++) for (int32 i = 0; i < Scripts.Count(); i++)
{ {