diff --git a/Code/Framework/AzCore/AzCore/Script/ScriptSystemComponent.cpp b/Code/Framework/AzCore/AzCore/Script/ScriptSystemComponent.cpp index f12da5c60e..015554538f 100644 --- a/Code/Framework/AzCore/AzCore/Script/ScriptSystemComponent.cpp +++ b/Code/Framework/AzCore/AzCore/Script/ScriptSystemComponent.cpp @@ -699,6 +699,10 @@ Data::AssetHandler::LoadResult ScriptSystemComponent::LoadAssetData( script->m_scriptBuffer.resize(scriptDataLength); stream->Read(scriptDataLength, script->m_scriptBuffer.data()); + // Clear cached references in the event of a successful load. This function has to be queued on + // AssetBus where NotifyAssetReloaded is also queued, to ensure its execution before NotifyAssetReloaded + Data::AssetBus::QueueFunction(&ScriptSystemComponent::ClearAssetReferences, this, asset.GetId()); + return Data::AssetHandler::LoadResult::LoadComplete; }