in Gems/Umbra/Code/Source/UmbraSceneComponent/EditorUmbraSceneComponent.cpp [98:161]
AZ::u32 EditorUmbraSceneComponent::ExportUmbraSceneFromUI()
{
// Before prompting the user for a scene file path, initialize it with the level name
AZStd::string levelName;
AzToolsFramework::EditorRequestBus::BroadcastResult(levelName, &AzToolsFramework::EditorRequestBus::Events::GetLevelName);
AZStd::to_lower(levelName.begin(), levelName.end());
AZStd::string scenePathSeed = AZ::Utils::GetProjectPath().c_str();
if (!levelName.empty())
{
scenePathSeed += "/";
scenePathSeed += levelName;
scenePathSeed += ".umbrascene";
}
// Prompt the user for a path to save the umbra scene
const AZStd::string scenePath = AzQtComponents::FileDialog::GetSaveFileName(
AzToolsFramework::GetActiveWindow(),
QString("Select Umbra Scene File Path"),
scenePathSeed.c_str(),
QString("Umbra Scene (*.umbrascene)"),
nullptr).toUtf8().constData();
if (!scenePath.empty())
{
if (!ExportUmbraScene(scenePath))
{
QMessageBox::critical(
AzToolsFramework::GetActiveWindow(),
QObject::tr("Umbra Scene Not Saved"),
QObject::tr("Failed to save umbra scene from level entities."));
return AZ::Edit::PropertyRefreshLevels::AttributesAndValues;
}
bool sceneAssetFound = false;
AZ::Data::AssetInfo sceneAssetInfo;
AZStd::string watchFolder;
AzToolsFramework::AssetSystemRequestBus::BroadcastResult(
sceneAssetFound,
&AzToolsFramework::AssetSystemRequestBus::Events::GetSourceInfoBySourcePath,
scenePath.c_str(),
sceneAssetInfo,
watchFolder);
if (!sceneAssetFound)
{
QMessageBox::critical(
AzToolsFramework::GetActiveWindow(),
QObject::tr("Umbra Scene Asset Not Assigned"),
QObject::tr("Failed to assign the umbra scene asset generated from level entities after saving."));
return AZ::Edit::PropertyRefreshLevels::AttributesAndValues;
}
AzToolsFramework::ScopedUndoBatch undoBatch("Setting scene asset.");
SetDirty();
UmbraSceneComponentRequestBus::Event(
GetEntityId(),
&UmbraSceneComponentRequestBus::Events::SetSceneAssetId,
AZ::Data::AssetId(sceneAssetInfo.m_assetId.m_guid, 0));
}
return AZ::Edit::PropertyRefreshLevels::EntireTree;
}