allow null parent to setParent

This commit is contained in:
Nick Fisher
2024-11-30 14:01:01 +08:00
parent c34c7d5545
commit fb650dbd52

View File

@@ -81,20 +81,30 @@ extern "C"
const auto child = Entity::import(childId);
const auto parent = Entity::import(parentId);
const auto &parentInstance = tm->getInstance(parent);
const auto &childInstance = tm->getInstance(child);
if (!childInstance.isValid())
{
Log("Child instance is not valid");
return;
}
if(parent.isNull()) {
Log("Unparenting child instance");
tm->setParent(childInstance, TransformManager::Instance());
return;
}
const auto &parentInstance = tm->getInstance(parent);
if (!parentInstance.isValid())
{
Log("Parent instance is not valid");
return;
}
if (!childInstance.isValid())
{
Log("Child instance is not valid");
return;
}
if (preserveScaling)
{