#include #include #include namespace Nz { template Asset AssetCatalog::LoadFromFile(const std::filesystem::path& path) { 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 { std::string filepath = asset.m_descriptor.path.string(); asset.m_resource = fs->Load(std::string_view(filepath), asset.m_descriptor.parameters); } if (!asset) // if it fails, use the default loader asset.m_resource = TResource::LoadFromFile(asset.m_descriptor.path, asset.m_descriptor.parameters); return asset; } }