Merge pull request #5070 from aws-lumberyard-dev/Atom/guthadam/material_component_clear_default_material_fixes

Fix clearing material component default material not updating
monroegm-disable-blank-issue-2
Guthrie Adams 4 years ago committed by GitHub
commit caf247fcab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1387,10 +1387,13 @@ namespace AzToolsFramework
QDataStream stream(&pixmapBytes, QIODevice::ReadOnly); QDataStream stream(&pixmapBytes, QIODevice::ReadOnly);
QPixmap pixmap; QPixmap pixmap;
stream >> pixmap; stream >> pixmap;
if (!pixmap.isNull())
{
GUI->SetBrowseButtonIcon(pixmap); GUI->SetBrowseButtonIcon(pixmap);
} }
} }
} }
}
else if (attrib == AZ_CRC_CE("BrowseButtonEnabled")) else if (attrib == AZ_CRC_CE("BrowseButtonEnabled"))
{ {
bool enabled = true; bool enabled = true;
@ -1417,6 +1420,8 @@ namespace AzToolsFramework
} }
else if (attrib == AZ_CRC_CE("ThumbnailIcon")) else if (attrib == AZ_CRC_CE("ThumbnailIcon"))
{ {
GUI->SetCustomThumbnailEnabled(false);
AZStd::string iconPath; AZStd::string iconPath;
if (attrValue->Read<AZStd::string>(iconPath) && !iconPath.empty()) if (attrValue->Read<AZStd::string>(iconPath) && !iconPath.empty())
{ {
@ -1434,11 +1439,14 @@ namespace AzToolsFramework
QDataStream stream(&pixmapBytes, QIODevice::ReadOnly); QDataStream stream(&pixmapBytes, QIODevice::ReadOnly);
QPixmap pixmap; QPixmap pixmap;
stream >> pixmap; stream >> pixmap;
if (!pixmap.isNull())
{
GUI->SetCustomThumbnailEnabled(true); GUI->SetCustomThumbnailEnabled(true);
GUI->SetCustomThumbnailPixmap(pixmap); GUI->SetCustomThumbnailPixmap(pixmap);
} }
} }
} }
}
else if (attrib == AZ_CRC_CE("ThumbnailCallback")) else if (attrib == AZ_CRC_CE("ThumbnailCallback"))
{ {
PropertyAssetCtrl::EditCallbackType* func = azdynamic_cast<PropertyAssetCtrl::EditCallbackType*>(attrValue->GetAttribute()); PropertyAssetCtrl::EditCallbackType* func = azdynamic_cast<PropertyAssetCtrl::EditCallbackType*>(attrValue->GetAttribute());

@ -66,17 +66,10 @@ namespace AzToolsFramework
} }
void ThumbnailPropertyCtrl::SetThumbnailKey(Thumbnailer::SharedThumbnailKey key, const char* contextName) void ThumbnailPropertyCtrl::SetThumbnailKey(Thumbnailer::SharedThumbnailKey key, const char* contextName)
{
if (m_customThumbnailEnabled)
{
ClearThumbnail();
}
else
{ {
m_key = key; m_key = key;
m_thumbnail->SetThumbnailKey(m_key, contextName); m_thumbnail->SetThumbnailKey(m_key, contextName);
m_thumbnailEnlarged->SetThumbnailKey(m_key, contextName); m_thumbnailEnlarged->SetThumbnailKey(m_key, contextName);
}
UpdateVisibility(); UpdateVisibility();
} }

@ -121,8 +121,13 @@ namespace AZ
MaterialComponentRequestBus::Handler::BusDisconnect(); MaterialComponentRequestBus::Handler::BusDisconnect();
MaterialReceiverNotificationBus::Handler::BusDisconnect(); MaterialReceiverNotificationBus::Handler::BusDisconnect();
TickBus::Handler::BusDisconnect(); TickBus::Handler::BusDisconnect();
ReleaseMaterials(); ReleaseMaterials();
// Sending notification to wipe any previously assigned material overrides
MaterialComponentNotificationBus::Event(
m_entityId, &MaterialComponentNotifications::OnMaterialsUpdated, MaterialAssignmentMap());
m_queuedMaterialUpdateNotification = false; m_queuedMaterialUpdateNotification = false;
m_entityId = AZ::EntityId(AZ::EntityId::InvalidEntityId); m_entityId = AZ::EntityId(AZ::EntityId::InvalidEntityId);
} }
@ -221,6 +226,11 @@ namespace AZ
if (!anyQueued) if (!anyQueued)
{ {
ReleaseMaterials(); ReleaseMaterials();
// If no other materials were loaded, the notification must still be sent in case there are externally managed material
// instances in the configuration
MaterialComponentNotificationBus::Event(
m_entityId, &MaterialComponentNotifications::OnMaterialsUpdated, m_configuration.m_materials);
} }
} }
@ -268,8 +278,6 @@ namespace AZ
{ {
materialPair.second.Release(); materialPair.second.Release();
} }
MaterialComponentNotificationBus::Event(m_entityId, &MaterialComponentNotifications::OnMaterialsUpdated, m_configuration.m_materials);
} }
MaterialAssignmentMap MaterialComponentController::GetOriginalMaterialAssignments() const MaterialAssignmentMap MaterialComponentController::GetOriginalMaterialAssignments() const

Loading…
Cancel
Save