No longer can create camera in an empty level (#5189)

Signed-off-by: Mikhail Naumov <mnaumov@amazon.com>
monroegm-disable-blank-issue-2
Mikhail Naumov 4 years ago committed by GitHub
parent 47b7ad1ec4
commit 22b21acc97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1124,7 +1124,9 @@ void EditorViewportWidget::OnTitleMenu(QMenu* menu)
action = menu->addAction(tr("Create camera entity from current view")); action = menu->addAction(tr("Create camera entity from current view"));
connect(action, &QAction::triggered, this, &EditorViewportWidget::OnMenuCreateCameraEntityFromCurrentView); connect(action, &QAction::triggered, this, &EditorViewportWidget::OnMenuCreateCameraEntityFromCurrentView);
if (!gameEngine || !gameEngine->IsLevelLoaded()) const auto prefabEditorEntityOwnershipInterface = AZ::Interface<AzToolsFramework::PrefabEditorEntityOwnershipInterface>::Get();
if (!gameEngine || !gameEngine->IsLevelLoaded() ||
(prefabEditorEntityOwnershipInterface && !prefabEditorEntityOwnershipInterface->IsRootPrefabAssigned()))
{ {
action->setEnabled(false); action->setEnabled(false);
action->setToolTip(tr(AZ::ViewportHelpers::TextCantCreateCameraNoLevel)); action->setToolTip(tr(AZ::ViewportHelpers::TextCantCreateCameraNoLevel));

@ -20,6 +20,7 @@
#include <AzToolsFramework/Entity/EditorEntityContextBus.h> #include <AzToolsFramework/Entity/EditorEntityContextBus.h>
#include <AzToolsFramework/API/EntityCompositionRequestBus.h> #include <AzToolsFramework/API/EntityCompositionRequestBus.h>
#include <AzToolsFramework/Entity/EditorEntityHelpers.h> #include <AzToolsFramework/Entity/EditorEntityHelpers.h>
#include <AzToolsFramework/Entity/PrefabEditorEntityOwnershipInterface.h>
#include <AzToolsFramework/API/EditorCameraBus.h> #include <AzToolsFramework/API/EditorCameraBus.h>
#include "ViewportCameraSelectorWindow.h" #include "ViewportCameraSelectorWindow.h"
@ -70,7 +71,20 @@ namespace Camera
if (!(flags & AzToolsFramework::EditorEvents::eECMF_HIDE_ENTITY_CREATION)) if (!(flags & AzToolsFramework::EditorEvents::eECMF_HIDE_ENTITY_CREATION))
{ {
QAction* action = menu->addAction(QObject::tr("Create camera entity from view")); QAction* action = menu->addAction(QObject::tr("Create camera entity from view"));
QObject::connect(action, &QAction::triggered, [this]() { CreateCameraEntityFromViewport(); }); const auto prefabEditorEntityOwnershipInterface = AZ::Interface<AzToolsFramework::PrefabEditorEntityOwnershipInterface>::Get();
if (prefabEditorEntityOwnershipInterface && !prefabEditorEntityOwnershipInterface->IsRootPrefabAssigned())
{
action->setEnabled(false);
}
else
{
QObject::connect(
action, &QAction::triggered,
[this]()
{
CreateCameraEntityFromViewport();
});
}
} }
} }

Loading…
Cancel
Save