Is it possible to access a node from the Material Editor from a C++ script?
I'd like to be able to change the value of 'Mulitply' from a script.
Is it possible to access a node from the Material Editor from a C++ script?
I'd like to be able to change the value of 'Mulitply' from a script.
In your Material, create a Scalar Parameter (hold 1 on the material grid and left click), name it and plug it in to your multiply node.
In your C++ header, create an instance variable and set it as a UPROPERTY so it doesn't get garbage collected.
UPROPERTY()
UMaterialInstanceDynamic* DynMat;
In your C++ constructor, set the dynamic material instance from the existing material on your mesh then set it to your mesh.
DynMat = UMaterialInstanceDynamic::Create(YOURMESHNAME->GetMaterial(0), this);
YOURMESHNAME->SetMaterial(0, DynMat)
The 0 in the get and set refer to which Element of the mesh the material is set to. If 0 is the back of the card and 1 is the front, change the code accordingly.
From here, you can use the DynMat reference to change your parameter values as follows.
MI->SetScalarParameterValue(TEXT("YourMultiplierName"), NewFloatValue);
YourMultiplierName must match exactly what you put in for the name of the parameter in the material grid, otherwise this won't work.