Fix crash when changing actor scene

This commit is contained in:
Wojtek Figat
2022-08-25 20:54:25 +02:00
parent 98616f443b
commit 88b46d1720

View File

@@ -103,22 +103,28 @@ void Actor::SetSceneInHierarchy(Scene* scene)
void Actor::OnEnableInHierarchy() void Actor::OnEnableInHierarchy()
{ {
OnEnable(); if (IsActiveInHierarchy() && GetScene() && !_isEnabled)
for (int32 i = 0; i < Children.Count(); i++)
{ {
Children[i]->OnEnableInHierarchy(); OnEnable();
for (int32 i = 0; i < Children.Count(); i++)
{
Children[i]->OnEnableInHierarchy();
}
} }
} }
void Actor::OnDisableInHierarchy() void Actor::OnDisableInHierarchy()
{ {
for (int32 i = 0; i < Children.Count(); i++) if (IsActiveInHierarchy() && GetScene() && _isEnabled)
{ {
Children[i]->OnDisableInHierarchy(); for (int32 i = 0; i < Children.Count(); i++)
} {
Children[i]->OnDisableInHierarchy();
}
OnDisable(); OnDisable();
}
} }
bool Actor::IsSubClassOf(const Actor* object, const MClass* klass) bool Actor::IsSubClassOf(const Actor* object, const MClass* klass)