25>Module.UFileImporter.cpp.obj : error LNK2019: unresolved external symbol “public: void __cdecl FMaterialUniformExpressionTexture::SetTransientOverrideTextureValue(class UTexture *)” (?SetTransientOverrideTextureValue@FMaterialUniformExpressionTexture@@QEAAXPEAVUTexture@@@Z) referenced in function “public: class UMaterial * __cdecl UMyFileImporter::CreateMaterial(class FString)” (?CreateMaterial@UMyFileImporter@@QEAAPEAVUMaterial@@VFString@@@Z)
25>C:\Unreal Source\Unreal 7-13-15\I\Engine\Plugins\Developer\UFileImporter\Binaries\Win64\UE4Editor-UFileImporter-Win64-Debug.dll : fatal error LNK1120: 1 unresolved externals
25>ERROR : UBT error : Failed to produce item: C:\Unreal Source\Unreal 7-13-15\I\Engine\Plugins\Developer\UFileImporter\Binaries\Win64\UE4Editor-UFileImporter-Win64-Debug.dll
25> Total build time: 46.48 seconds
25>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command "..\..\Build\BatchFiles\Build.bat UE4Editor Win64 Debug" exited with code -1.
When I use the method SetTransientOverrideTextureValue I get this error. I haven’t figured out why yet. I know this method is used within the engine but I’m trying to forcefully switch out textures in a material that I have imported in outside the project.
Here’s the code:
UMaterial* mat = NewObject<UMaterial>();
ERHIFeatureLevel::Type FeatureLevelsToUpdate[1] = { GetWorld()->FeatureLevel };
int32 NumFeatureLevelsToUpdate = 1;
for (int32 i = 0; i < NumFeatureLevelsToUpdate; i++)
{
FMaterialResource* Resource = mat->GetMaterialResource(FeatureLevelsToUpdate[i]);
const TArray<TRefCountPtr<FMaterialUniformExpressionTexture>>* ExpressionsByType[2] =
{
&Resource->GetUniform2DTextureExpressions(),
&Resource->GetUniformCubeTextureExpressions()
};
for (int32 TypeIndex = 0; TypeIndex < ARRAY_COUNT(ExpressionsByType); TypeIndex++)
{
for (FMaterialUniformExpressionTexture* Expression : *ExpressionsByType[TypeIndex])
{
const bool bAllowOverride = false;
UTexture* Texture = NULL;
Expression->GetGameThreadTextureValue(mat, *Resource, Texture, bAllowOverride);
Expression->SetTransientOverrideTextureValue(Import(Path));
}
}
}
Hey
Where is the code that you posted located in the engine? I was able to find SetTransientTextureOverride() but I did not find a SetTransientOverrideTextureValue() function in the engine. Additionally, I’m not sure I understand what you’re trying to accomplish. It sounds as though the textures you want to use are not assets in the project, is this accurate? Are you able to import the textures into the project rather than trying to access them from somewhere else?
What I am ultimately trying to do is allow for runtime importation of files outside the project, in this case images. I will takes these images and make them into UTexture2D. From here I was trying to see if it would be easier to create my own UMaterial and UMaterialInterface or use preexisting ones. I wanted to switch out textures on a static mesh component when the application first runs
I know this is digging into a lot of stuff which is probably violating the EULA but these edits are for in house use and not distrabution.
The code I posted was from my own method heavily based from material.cpp’s overrideTexture method
After digging farther into the files I realized that the material variable is missing a lot of components and it would probably be easier to use an already existing material. Although i’m not sure there the material and the textures are actually linked so finding how to change the material on a method is my next step
Hey
It should be possible to switch a texture during runtime however it would not be an easy task. To do so you would need to set up a dynamic material instance and then change the texture parameter. If the texture being used is saved outside of the project then you need to hardcode the path to the texture. If the texture is saved on a web server you would need to include the URL to the texture as well as make sure that the game is able to connect to the internet to retrieve the texture. Depending on the number of images and reasoning, it may be a better option to bring the images into the editor to make referencing them easier.
Cheers
Thank you very much
There will be a proxy that will provide the path to where the pictures are located. It won’t be the same pictures everytime.
When I pick the parent material for the dynamic material that seems to override the dynamic material and only show the texture of the parent
I’m not sure if that means that its not actually getting a texture to show or if something else is going on
Hi KikyoPorter -
I’ve been helping on this question and I want to make sure we are understanding you correctly. You should be creating a new Dynamic Material Instance referencing the base material as a template. You cannot simply force a material to be dynamic, the engine views those separately and a Dynamic Material needs a base to derive from.
Is this how you are handling the coding?
Thank You for the clarification -
Eric Ketchum
Yes so I created a dynamic Material Instance with the parent material being the original material
So it sounds like the setup is correct, does the original material show as expected before trying to change it? How are you using the DMI after creating it? Could you post the code that you’re using to change the DMI material as well as how the code is called?
I actually found a way to import an image from my hard drive and its showing up. I just have to make sure I just make a copy of the original material and not a pointer otherwise when I change it, it will change the original material and cause errors.