From d304c56898c51ae2d9378e60e2ce7dec33a0cf02 Mon Sep 17 00:00:00 2001 From: SweetId <2630750+SweetId@users.noreply.github.com> Date: Mon, 11 Mar 2024 19:08:29 -0400 Subject: [PATCH] [Assets] load Json through filesystem if available --- include/Nazara/Core/AssetCatalog.inl | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/include/Nazara/Core/AssetCatalog.inl b/include/Nazara/Core/AssetCatalog.inl index 292d6b73b..97b07eb97 100644 --- a/include/Nazara/Core/AssetCatalog.inl +++ b/include/Nazara/Core/AssetCatalog.inl @@ -15,16 +15,15 @@ namespace Nz { Asset asset; - JsonSerializationContext json; - if (!json.Load(path)) - return {}; - - if (!Unserialize(json, "", &asset.m_descriptor)) - return {}; - FilesystemAppComponent* fs = ApplicationBase::Instance()->TryGetComponent(); if (fs) // first try using a FileSystem component to load the asset { + auto json = fs->Load(std::string_view(path.string())); + + if (!Unserialize(*json, "", &asset.m_descriptor)) + return {}; + + std::string filepath = asset.m_descriptor.path.string(); if constexpr (IsStreamingResource) { @@ -38,6 +37,13 @@ namespace Nz if (!asset) // if it fails, use the default loader { + JsonSerializationContext json; + if (!json.Load(path)) + return {}; + + if (!Unserialize(json, "", &asset.m_descriptor)) + return {}; + if constexpr (IsStreamingResource) { asset.m_resource = TResource::OpenFromFile(asset.m_descriptor.path, asset.m_descriptor.parameters);