怎么在蓝图输入图片路​径字符串,然后贴到模型材质上

请问怎么在蓝图里多次改一个模型的材质呢, 比如有3000张图片,我想转换成材质轮流贴在一个模型上,用摄像机采集,我在蓝图里只找到一个手动选择材质的节点,没办法自动化。怎么在蓝图输入图片路​径字符串,然后贴到模型材质上

这你需要使用蓝图c++写一个API转换为导出的Material使用,
由于不知道你具体的工程项目,我写一个代码框架供抛砖引玉
// YourProject/Source/YourProject/Public/YourProject.h

#pragma once

include “CoreMinimal.h”
include “Kismet/BlueprintFunctionLibrary.h”
include “YourProject.generated.h”

/**
*
*/
UCLASS()
class YOURPROJECT_API UYourProjectAPI : public UBlueprintFunctionLibrary
{
GENERATED_BODY()

public:
UFUNCTION(BlueprintCallable, Category = “YourProject”)
static UMaterial* LoadMaterialFromFile(const FString& FilePath);
};
// YourProject/Source/YourProject/Private/YourProject.cpp

include “YourProject.h”

UMaterial* UYourProjectAPI::LoadMaterialFromFile(const FString& FilePath)
{
// 这里应该有逻辑来加载文件路径指向的图片,并将其转换为一个Material
// 为了简化,我们只是简单地返回一个示例Material
if (FilePath == TEXT(“Path/To/Your/Image”))
{
// 假设这个Material已经预先创建并导入了项目资源中
return LoadObject(nullptr, TEXT(“Material’/YourProject/ExampleMaterial.ExampleMaterial’”));
}

return nullptr;

}
// YourProject/Source/YourProject/Public/BP_YourProjectAPI.h

#pragma once

include “CoreMinimal.h”
include “Kismet/BlueprintFunctionLibrary.h”
include “BP_YourProjectAPI.generated.h”

/**
*
*/
UCLASS()
class YOURPROJECT_API UBP_YourProjectAPI : public UBlueprintFunctionLibrary
{
GENERATED_BODY()

public:
UFUNCTION(BlueprintCallable, Category = “YourProject”)
static UMaterial* LoadMaterialFromFile(const FString& FilePath);
};
// YourProject/Source/YourProject/Private/BP_YourProjectAPI.cpp

include “BP_YourProjectAPI.h”
include “YourProjectAPI.h”

UMaterial* UBP_YourProjectAPI::LoadMaterialFromFile(const FString& FilePath)
{
// 调用C++ API函数
return UYourProjectAPI::LoadMaterialFromFile(FilePath);
}