Hi,
I try to change the parent Material of the Material Instances which are in a specific folder of my project. I would like to create a function that archieve this and run it from the editor.
Any Idea ?
Thank you !
Hi,
I try to change the parent Material of the Material Instances which are in a specific folder of my project. I would like to create a function that archieve this and run it from the editor.
Any Idea ?
Thank you !
The solution:
UMaterial* BaseMat = LoadMaterialFromPath(MaterialPath);
UMaterialInstance* MatIns = LoadMaterialInstanceFromPath(InstancePath);
MatIns->Parent = BaseMat;
With loading functions :
UFUNCTION(BlueprintCallable, Category = "save")
static FORCEINLINE ObjClass* LoadObjFromPath(const FString& Path)
{
if (Path == "") return NULL;
return Cast<ObjClass>(StaticLoadObject(ObjClass::StaticClass(), NULL, *Path));
}
UFUNCTION(BlueprintCallable, Category = "save")
static FORCEINLINE UMaterial* LoadMaterialFromPath(const FString& Path)
{
if (Path == "") return NULL;
return LoadObjFromPath<UMaterial>(Path);
}
UFUNCTION(BlueprintCallable, Category = "save")
static FORCEINLINE UMaterialInstance* LoadMaterialInstanceFromPath(const FString& Path)
{
if (Path == "") return NULL;
return LoadObjFromPath<UMaterialInstance>(Path);
}
Is it possible to do it with blueprint?