modify not show path componet

This commit is contained in:
brige 2025-11-09 16:02:42 +08:00
parent 5e6b554f90
commit 9c6dd93ef7
3 changed files with 45 additions and 5 deletions

View File

@ -109,6 +109,25 @@ Entity* EntitiesManager::CreateMesh(const QString& mesh) {
SceneComponent* conponent = ComponentFactory::Create("MeshComponent", nullptr);
conponent->SetAttribute("mesh", mesh.toStdString().c_str());
conponent->AttachEntity(entity);
// Also add PathComponent so the entity has a path attribute by default
SceneComponent* rootComponent = entity->GetRootComponent();
if (rootComponent) {
SceneComponent* pathComponent = ComponentFactory::Create("PathComponent", rootComponent);
if (pathComponent) {
pathComponent->AttachTo(rootComponent);
LOG_INFO("EntitiesManager::CreateMesh - Added PathComponent");
} else {
LOG_WARN("EntitiesManager::CreateMesh - Failed to create PathComponent");
}
} else {
SceneComponent* pathComponent = ComponentFactory::Create("PathComponent", nullptr);
if (pathComponent) {
pathComponent->AttachEntity(entity);
LOG_INFO("EntitiesManager::CreateMesh - Added PathComponent with no root");
} else {
LOG_WARN("EntitiesManager::CreateMesh - Failed to create PathComponent with no root");
}
}
return entity;
}

View File

@ -66,6 +66,28 @@ Entity* EntityFactory::CreateEntityWithComponents(const QString& type, const QSt
}
}
// Always add PathComponent so entity has path attribute editable in PropertyBrowser
{
SceneComponent* rootComponent = entity->GetRootComponent();
if (nullptr == rootComponent) {
SceneComponent* pathComponent = ComponentFactory::Create("PathComponent", nullptr);
if (pathComponent) {
pathComponent->AttachEntity(entity);
LOG_INFO("EntityFactory::CreateEntityWithComponents - Added PathComponent");
} else {
LOG_WARN("EntityFactory::CreateEntityWithComponents - Failed to create PathComponent");
}
} else {
SceneComponent* pathComponent = ComponentFactory::Create("PathComponent", rootComponent);
if (pathComponent) {
pathComponent->AttachTo(rootComponent);
LOG_INFO("EntityFactory::CreateEntityWithComponents - Added PathComponent");
} else {
LOG_WARN("EntityFactory::CreateEntityWithComponents - Failed to create PathComponent");
}
}
}
// Add required components
QStringList requiredComponents = it->second->GetRequiredComponents();
SceneComponent* rootComponent = entity->GetRootComponent();

View File

@ -9308,7 +9308,7 @@ void QtMeshComponetManager::SetPropertyValue(QtProperty* property, SceneComponen
}
QString QtMeshComponetManager::GetPropertyId() const {
return tr("MeshComponent");
return QStringLiteral("MeshComponent");
}
/*!
@ -9467,9 +9467,8 @@ void QtPathComponentManager::SetPropertyValue(QtProperty* property, SceneCompone
}
QString QtPathComponentManager::GetPropertyId() const {
return tr("PathComponent");
return QStringLiteral("PathComponent");
}
/*!
Returns the given \a property's value.
@ -9732,7 +9731,7 @@ void QtConeWaveComponentManager::SetPropertyValue(QtProperty* property, SceneCom
}
QString QtConeWaveComponentManager::GetPropertyId() const {
return tr("ConeWaveComponent");
return QStringLiteral("ConeWaveComponent");
}
/*!
@ -10073,7 +10072,7 @@ void QtDashedLineComponentManager::SetPropertyValue(QtProperty* property, SceneC
}
QString QtDashedLineComponentManager::GetPropertyId() const {
return tr("DashedLineComponent");
return QStringLiteral("DashedLineComponent");
}
QDashedLineComponentAttribute QtDashedLineComponentManager::value(const QtProperty* property) const {