TLDR: how to access the parameters of a given material/material instance in BP and/or C++.
I would like to expose material parameters to the UI so the player can edit material instances at runtime(i.e. color, roughness of objects, etc).
I have a base class, that is the parent of everything in game; that has a variable of type Material Instance Dynamic called WMaterialInstance. It also has an Interface function to return that var.
I’d like read parameters of this instance and expose it to the UI somehow.
But I can’t get those parameters…
I am using a Get Scalar Values node to get my params…
I tried feeding it a Material Instance Dynamic reference, but my Print String nodes return zero, although there are parameters on the material, 100%.
Please see the BP nodes here.
I found a postdescribing a similar issue.
One of the answers says:
So I got the parent of my Material Instance Dynamic and tried casting it to just a normal MaterialInstance, but the cast seems to fail, if I feed the parent to it…
Note: the Get Material node is my interface call to the Dynamic Instance from construction script, not the built in one.
Further down in the post there is an answer saying:
I created a material instance from my original material and assigned it to one of the child classes of the baseclass, so I use that one in the base construction script.
Still, doesn’t want to work… I get the same zeros and cast failures…
I noticed, that if I Print String the Display name of the Parent I get from the accessed base material it prints WorldGridMaterial, which means, it did not find what it supposed to…
Did anyone experience something similar?
Is there a better way to access these parameters?