[LYN-3717] When pulling in an actor FBX, two entities are spawned & [ATOM-15258] Clicking and Dragging fbx file into viewport produces 2 entities (#1392)
* [LYN-3717] When pulling in an actor FBX, two entities are spawned & [ATOM-15258] Clicking and Dragging fbx file into viewport produces 2 entities * Added another operation to the CanSpawnEntityForProduct that checks the other products and can veto the creation process. * The model product will not create an entity in case there is already an actor exported, which prevents the issue reported by two different teams/users.
This commit is contained in:
@@ -56,7 +56,8 @@ namespace AzAssetBrowserRequestHandlerPrivate
|
||||
using namespace AzToolsFramework;
|
||||
using namespace AzToolsFramework::AssetBrowser;
|
||||
// return true ONLY if we can handle the drop request in the viewport.
|
||||
bool CanSpawnEntityForProduct(const ProductAssetBrowserEntry* product)
|
||||
bool CanSpawnEntityForProduct(const ProductAssetBrowserEntry* product,
|
||||
AZStd::optional<const AZStd::vector<AZ::Data::AssetType>> optionalProductAssetTypes = AZStd::nullopt)
|
||||
{
|
||||
if (!product)
|
||||
{
|
||||
@@ -70,7 +71,6 @@ namespace AzAssetBrowserRequestHandlerPrivate
|
||||
|
||||
bool canCreateComponent = false;
|
||||
AZ::AssetTypeInfoBus::EventResult(canCreateComponent, product->GetAssetType(), &AZ::AssetTypeInfo::CanCreateComponent, product->GetAssetId());
|
||||
|
||||
if (!canCreateComponent)
|
||||
{
|
||||
return false;
|
||||
@@ -78,16 +78,25 @@ namespace AzAssetBrowserRequestHandlerPrivate
|
||||
|
||||
AZ::Uuid componentTypeId = AZ::Uuid::CreateNull();
|
||||
AZ::AssetTypeInfoBus::EventResult(componentTypeId, product->GetAssetType(), &AZ::AssetTypeInfo::GetComponentTypeId);
|
||||
|
||||
if (!componentTypeId.IsNull())
|
||||
if (componentTypeId.IsNull())
|
||||
{
|
||||
// we have a component type that handles this asset.
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (optionalProductAssetTypes.has_value())
|
||||
{
|
||||
bool hasConflictingProducts = false;
|
||||
AZ::AssetTypeInfoBus::EventResult(hasConflictingProducts, product->GetAssetType(), &AZ::AssetTypeInfo::HasConflictingProducts, optionalProductAssetTypes.value());
|
||||
if (hasConflictingProducts)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// additional operations can be added here.
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void SpawnEntityAtPoint(const ProductAssetBrowserEntry* product, AzQtComponents::ViewportDragContext* viewportDragContext, EntityIdList& spawnList, AzFramework::SliceInstantiationTicket& spawnTicket)
|
||||
@@ -511,9 +520,16 @@ void AzAssetBrowserRequestHandler::Drop(QDropEvent* event, AzQtComponents::DragA
|
||||
}
|
||||
|
||||
// Handle products
|
||||
AZStd::vector<AZ::Data::AssetType> productAssetTypes;
|
||||
productAssetTypes.reserve(products.size());
|
||||
for (const AzToolsFramework::AssetBrowser::ProductAssetBrowserEntry* entry : products)
|
||||
{
|
||||
productAssetTypes.emplace_back(entry->GetAssetType());
|
||||
}
|
||||
|
||||
for (const ProductAssetBrowserEntry* product : products)
|
||||
{
|
||||
if (CanSpawnEntityForProduct(product))
|
||||
if (CanSpawnEntityForProduct(product, productAssetTypes))
|
||||
{
|
||||
SpawnEntityAtPoint(product, viewportDragContext, spawnedEntities, spawnTicket);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user