[Assets] load Json through filesystem if available
This commit is contained in:
parent
8cc1719d1b
commit
d304c56898
|
|
@ -15,16 +15,15 @@ namespace Nz
|
|||
{
|
||||
Asset<TResource> asset;
|
||||
|
||||
JsonSerializationContext json;
|
||||
if (!json.Load(path))
|
||||
return {};
|
||||
|
||||
if (!Unserialize(json, "", &asset.m_descriptor))
|
||||
return {};
|
||||
|
||||
FilesystemAppComponent* fs = ApplicationBase::Instance()->TryGetComponent<FilesystemAppComponent>();
|
||||
if (fs) // first try using a FileSystem component to load the asset
|
||||
{
|
||||
auto json = fs->Load<JsonSerializationContext>(std::string_view(path.string()));
|
||||
|
||||
if (!Unserialize(*json, "", &asset.m_descriptor))
|
||||
return {};
|
||||
|
||||
|
||||
std::string filepath = asset.m_descriptor.path.string();
|
||||
if constexpr (IsStreamingResource<TResource>)
|
||||
{
|
||||
|
|
@ -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<TResource>)
|
||||
{
|
||||
asset.m_resource = TResource::OpenFromFile(asset.m_descriptor.path, asset.m_descriptor.parameters);
|
||||
|
|
|
|||
Loading…
Reference in New Issue