No longer can create camera in an empty level (#5189)
Signed-off-by: Mikhail Naumov <mnaumov@amazon.com>
This commit is contained in:
@@ -1124,7 +1124,9 @@ void EditorViewportWidget::OnTitleMenu(QMenu* menu)
|
||||
action = menu->addAction(tr("Create camera entity from current view"));
|
||||
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->setToolTip(tr(AZ::ViewportHelpers::TextCantCreateCameraNoLevel));
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
#include <AzToolsFramework/API/EntityCompositionRequestBus.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
|
||||
#include <AzToolsFramework/Entity/PrefabEditorEntityOwnershipInterface.h>
|
||||
|
||||
#include <AzToolsFramework/API/EditorCameraBus.h>
|
||||
#include "ViewportCameraSelectorWindow.h"
|
||||
@@ -70,7 +71,20 @@ namespace Camera
|
||||
if (!(flags & AzToolsFramework::EditorEvents::eECMF_HIDE_ENTITY_CREATION))
|
||||
{
|
||||
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();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user