Prepare script lifecycle and data layer
This commit is contained in:
@@ -8,5 +8,35 @@ TransformComponent& Component::transform() const {
|
||||
return *m_gameObject->GetTransform();
|
||||
}
|
||||
|
||||
Scene* Component::GetScene() const {
|
||||
return m_gameObject ? m_gameObject->GetScene() : nullptr;
|
||||
}
|
||||
|
||||
void Component::SetEnabled(bool enabled) {
|
||||
if (m_enabled == enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool wasEffectivelyEnabled = m_enabled;
|
||||
bool isEffectivelyEnabled = enabled;
|
||||
|
||||
if (m_gameObject) {
|
||||
wasEffectivelyEnabled = m_enabled && m_gameObject->IsActiveInHierarchy();
|
||||
isEffectivelyEnabled = enabled && m_gameObject->IsActiveInHierarchy();
|
||||
}
|
||||
|
||||
m_enabled = enabled;
|
||||
|
||||
if (wasEffectivelyEnabled == isEffectivelyEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isEffectivelyEnabled) {
|
||||
OnEnable();
|
||||
} else {
|
||||
OnDisable();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user