Add UseAssetImportPathRelative to Editor options and use it by default to store imported asset path relative to the project folder
This commit is contained in:
@@ -4,15 +4,16 @@
|
||||
#include "Cache/AssetsCache.h"
|
||||
#include "Storage/ContentStorageManager.h"
|
||||
#include "Loading/Tasks/LoadAssetDataTask.h"
|
||||
#include "Factories/BinaryAssetFactory.h"
|
||||
#include "Engine/ContentImporters/AssetsImportingManager.h"
|
||||
#include "Engine/Content/Content.h"
|
||||
#include "Engine/Serialization/JsonTools.h"
|
||||
#include "Engine/Debug/Exceptions/JsonParseException.h"
|
||||
#include "Factories/BinaryAssetFactory.h"
|
||||
#include "Engine/Threading/ThreadPoolTask.h"
|
||||
#if USE_EDITOR
|
||||
#include "Engine/Platform/FileSystem.h"
|
||||
#include "Engine/Threading/Threading.h"
|
||||
#include "Engine/Engine/Globals.h"
|
||||
#endif
|
||||
|
||||
REGISTER_BINARY_ASSET_ABSTRACT(BinaryAsset, "FlaxEngine.BinaryAsset");
|
||||
@@ -123,6 +124,12 @@ void BinaryAsset::GetImportMetadata(String& path, String& username) const
|
||||
{
|
||||
path = JsonTools::GetString(document, "ImportPath");
|
||||
username = JsonTools::GetString(document, "ImportUsername");
|
||||
if (path.HasChars() && FileSystem::IsRelative(path))
|
||||
{
|
||||
// Convert path back to thr absolute (eg. if stored in relative format)
|
||||
path = Globals::ProjectFolder / path;
|
||||
StringUtils::PathRemoveRelativeParts(path);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#if COMPILE_WITH_ASSETS_IMPORTER
|
||||
|
||||
#include "AssetsImportingManager.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Core/Utilities.h"
|
||||
#include "Engine/Serialization/JsonWriters.h"
|
||||
#include "Engine/Threading/MainThreadTask.h"
|
||||
@@ -10,9 +11,9 @@
|
||||
#include "Engine/Content/Content.h"
|
||||
#include "Engine/Content/Cache/AssetsCache.h"
|
||||
#include "Engine/Engine/EngineService.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Platform/FileSystem.h"
|
||||
#include "Engine/Platform/Platform.h"
|
||||
#include "Engine/Engine/Globals.h"
|
||||
#include "ImportTexture.h"
|
||||
#include "ImportModelFile.h"
|
||||
#include "ImportAudio.h"
|
||||
@@ -71,6 +72,7 @@ AssetsImportingManagerService AssetsImportingManagerServiceInstance;
|
||||
|
||||
Array<AssetImporter> AssetsImportingManager::Importers;
|
||||
Array<AssetCreator> AssetsImportingManager::Creators;
|
||||
bool AssetsImportingManager::UseImportPathRelative = false;
|
||||
|
||||
CreateAssetContext::CreateAssetContext(const StringView& inputPath, const StringView& outputPath, const Guid& id, void* arg)
|
||||
{
|
||||
@@ -161,7 +163,15 @@ bool CreateAssetContext::AllocateChunk(int32 index)
|
||||
void CreateAssetContext::AddMeta(JsonWriter& writer) const
|
||||
{
|
||||
writer.JKEY("ImportPath");
|
||||
writer.String(InputPath);
|
||||
if (AssetsImportingManager::UseImportPathRelative && !FileSystem::IsRelative(InputPath))
|
||||
{
|
||||
const String relativePath = FileSystem::ConvertAbsolutePathToRelative(Globals::ProjectFolder, InputPath);
|
||||
writer.String(relativePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.String(InputPath);
|
||||
}
|
||||
writer.JKEY("ImportUsername");
|
||||
writer.String(Platform::GetUserName());
|
||||
}
|
||||
|
||||
@@ -22,6 +22,11 @@ public:
|
||||
/// </summary>
|
||||
static Array<AssetCreator> Creators;
|
||||
|
||||
/// <summary>
|
||||
/// If true store asset import path relative to the current workspace, otherwise will store absolute path.
|
||||
/// </summary>
|
||||
static bool UseImportPathRelative;
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// The create texture tag (using internal import pipeline to crate texture asset from custom image source).
|
||||
|
||||
Reference in New Issue
Block a user