Restored the code that clears the Lua asset cache
This commit is contained in:
@@ -349,7 +349,7 @@ ScriptLoadResult ScriptSystemComponent::LoadAndGetNativeContext(const Data::Asse
|
||||
|
||||
// Check if already loaded
|
||||
auto scriptIt = container->m_loadedScripts.find(asset.GetId().m_guid);
|
||||
if (scriptIt != container->m_loadedScripts.end())
|
||||
if (scriptIt != container->m_loadedScripts.end() && scriptIt->second.m_scriptAsset.Get())
|
||||
{
|
||||
lua_rawgeti(lua, LUA_REGISTRYINDEX, scriptIt->second.m_tableReference);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user