Fix asset paths to be from project rather than packages
This commit is contained in:
@@ -106,7 +106,7 @@ public:
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path to the asset storage.
|
||||
/// Gets the path to the asset storage file. In Editor it reflects the actual file, in cooked Game, it fakes the Editor path to be informative for developers.
|
||||
/// </summary>
|
||||
API_PROPERTY() virtual const String& GetPath() const = 0;
|
||||
|
||||
|
||||
@@ -446,7 +446,12 @@ void BinaryAsset::OnDeleteObject()
|
||||
|
||||
const String& BinaryAsset::GetPath() const
|
||||
{
|
||||
#if USE_EDITOR
|
||||
return Storage ? Storage->GetPath() : String::Empty;
|
||||
#else
|
||||
// In build all assets are packed into packages so use ID for original path lookup
|
||||
return Content::GetRegistry()->GetAssetPath(_id);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -233,6 +233,11 @@ bool AssetsCache::Save(const StringView& path, const Registry& entries, const Pa
|
||||
return false;
|
||||
}
|
||||
|
||||
const String& AssetsCache::GetAssetPath(const Guid& id) const
|
||||
{
|
||||
return _registry[id].Info.Path;
|
||||
}
|
||||
|
||||
bool AssetsCache::FindAsset(const StringView& path, AssetInfo& info)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
|
||||
@@ -128,6 +128,13 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Finds the asset path by id.
|
||||
/// </summary>
|
||||
/// <param name="id">The asset id.</param>
|
||||
/// <returns>The asset path, or empty if failed to find.</returns>
|
||||
const String& GetAssetPath(const Guid& id) const;
|
||||
|
||||
/// <summary>
|
||||
/// Finds the asset info by path.
|
||||
/// </summary>
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
#else
|
||||
#include "Storage/ContentStorageManager.h"
|
||||
#endif
|
||||
#include "Content.h"
|
||||
#include "FlaxEngine.Gen.h"
|
||||
#include "Cache/AssetsCache.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Serialization/JsonTools.h"
|
||||
#include "Engine/Content/Factories/JsonAssetFactory.h"
|
||||
@@ -39,7 +41,12 @@ String JsonAssetBase::GetData() const
|
||||
|
||||
const String& JsonAssetBase::GetPath() const
|
||||
{
|
||||
#if USE_EDITOR
|
||||
return _path;
|
||||
#else
|
||||
// In build all assets are packed into packages so use ID for original path lookup
|
||||
return Content::GetRegistry()->GetAssetPath(_id);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if USE_EDITOR
|
||||
@@ -94,7 +101,6 @@ Asset::LoadResult JsonAssetBase::loadAsset()
|
||||
{
|
||||
// Load data (raw json file in editor, cooked asset in build game)
|
||||
#if USE_EDITOR
|
||||
|
||||
BytesContainer data;
|
||||
if (File::ReadAllBytes(GetPath(), data))
|
||||
{
|
||||
@@ -105,9 +111,7 @@ Asset::LoadResult JsonAssetBase::loadAsset()
|
||||
{
|
||||
return LoadResult::MissingDataChunk;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// Get the asset storage container but don't load it now
|
||||
const auto storage = ContentStorageManager::GetStorage(GetPath(), true);
|
||||
if (!storage)
|
||||
@@ -125,7 +129,6 @@ Asset::LoadResult JsonAssetBase::loadAsset()
|
||||
if (storage->LoadAssetChunk(chunk))
|
||||
return LoadResult::CannotLoadData;
|
||||
auto& data = chunk->Data;
|
||||
|
||||
#endif
|
||||
|
||||
// Parse json document
|
||||
|
||||
Reference in New Issue
Block a user