python中如何修改DataTable的源文件的值,也即将csv导出为DT表后,清除DT表的源文件依赖

import unreal

import sys

import os

import re

def UpdateDT(fpath,dpath,structPath,logFile):

task \= unreal.AssetImportTask()

task.filename \= fpath

task.destination\_path \= dpath

task.replace\_existing \= True

task.automated \= True

task.save \= True



csv\_factory \= unreal.CSVImportFactory()

\# csv\_factory.automated\_import\_settings.import\_row\_struct \= unreal.load\_object(None, r'/Script/SPGameFramework.SP\_AudioConfigV1Set')

csv\_factory.automated\_import\_settings.import\_row\_struct \= unreal.load\_object(None, structPath)



task.factory \= csv\_factory



asset\_tools \= unreal.AssetToolsHelpers.get\_asset\_tools()

asset\_tools.import\_asset\_tasks(\[task])



asset\_paths \= task.get\_editor\_property("imported\_object\_paths")

success \= asset\_paths and len(asset\_paths) \> 0

return success

您好,是指去掉 assetimportinfo 里面的 sourcedata 吗?如果是的话,这一项并没有暴露给蓝图(python)

如果要修改的话需要自己写一个FunctionLibrary,在python中调用​

是的,需要实现类似在编辑器中的“数据表格细节”中的“源文件”处点右侧的×的效果,这个方便提供脚本吗? [Image Removed]

// h
 
UCLASS()
class TEST560_API UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()
	
	UFUNCTION(BlueprintCallable)
	static bool ClearDataTableSourceFileInfo(UDataTable* InDataTable, int32 Index = 0);
};
 
 
// cpp
bool UMyBlueprintFunctionLibrary::ClearDataTableSourceFileInfo(UDataTable* InDataTable, int32 Index)
{
	UAssetImportData* ImportData = InDataTable->AssetImportData;
	if (ImportData && ImportData->SourceData.SourceFiles.IsValidIndex(Index))
	{
		//Clear the filename, Hash and timestamp. Leave the Display label.
		ImportData->SourceData.SourceFiles[Index].RelativeFilename = FString();
		ImportData->SourceData.SourceFiles[Index].FileHash = FMD5Hash();
		ImportData->SourceData.SourceFiles[Index].Timestamp = 0;
		ImportData->GetOutermost()->MarkPackageDirty();
	}
	else
	{
		return false;
	}
 
    return true;
}

类似这样的吧,然后​在python中调用

UpdateDT(fpath, dpath,structPath)

dt = unreal.load_object(None, ‘/Game/csvtest’)

unreal.MyBlueprintFunctionLibrary.clear_data_table_source_file_info(dt)

unreal.EditorLoadingAndSavingUtils.save_packages([dt.get_outermost()], True)

感谢,问题已经成功解决了