Merge pull request #304 from aws-lumberyard-dev/Atom/santorac/ShaderCollectionItemFixMain-LYN-2905

Cherrypicked the fix from the 1.0 branch to main (see #301).

Added a check for m_shaderAsset.IsReady() before trying to use the asset data. Also added a check before calling BlockUntilLoadComplete() to prevent reporting an error message unnecessarily.

Set the reflection name for ShaderCollection::Item to "ShaderCollectionItem" so it doesn't show up as just "Item" in Script Canvas.
main
Chris Santora 5 years ago committed by GitHub
commit c371c3a6cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -40,13 +40,22 @@ namespace AZ
// Dependent asset references aren't guaranteed to finish loading by the time this asset is serialized, only by
// the time this asset load is completed. But since the data is needed here, we will deliberately block until the
// shader asset has finished loading.
shaderVariantReference->m_shaderAsset.QueueLoad();
shaderVariantReference->m_shaderAsset.BlockUntilLoadComplete();
shaderVariantReference->m_shaderOptionGroup = ShaderOptionGroup{
shaderVariantReference->m_shaderAsset->GetShaderOptionGroupLayout(),
shaderVariantReference->m_shaderVariantId
};
if (shaderVariantReference->m_shaderAsset.QueueLoad())
{
shaderVariantReference->m_shaderAsset.BlockUntilLoadComplete();
}
if (shaderVariantReference->m_shaderAsset.IsReady())
{
shaderVariantReference->m_shaderOptionGroup = ShaderOptionGroup{
shaderVariantReference->m_shaderAsset->GetShaderOptionGroupLayout(),
shaderVariantReference->m_shaderVariantId
};
}
else
{
shaderVariantReference->m_shaderOptionGroup = {};
}
}
};
@ -82,7 +91,7 @@ namespace AZ
if (BehaviorContext* behaviorContext = azrtti_cast<BehaviorContext*>(context))
{
behaviorContext->Class<Item>()
behaviorContext->Class<Item>("ShaderCollectionItem")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
->Attribute(AZ::Script::Attributes::Category, "Shader")
->Attribute(AZ::Script::Attributes::Module, "shader")

Loading…
Cancel
Save