[4.11][UMG] How to change parameters in a Material used in UMG

Hi,

so I’m currently trying to use a Material for a circular mask in my UMG widget. This is working just fine, but I just can’t get it to change on runtime.

I tried using a parameter collection in the material that’s changed in the level blueprint. Again, it’s working nicely, but it won’t work for the Widget, since that needs a Interface Material and those can’t handle parameter collection inputs. Apparently since 4.7

Then I tried using a dynamic instance material, but I just can’t figure out how to pass my variables from the level to the actual material in the widget.

I’m also using a widget that’s placed inside a Blueprint to place the widget in my scene. I tried a canvas texture earlier, but that was even more of a hassle and involved a lot of trial and error, just to get stuck on the same problem.

So how exactly can I control the material referenced as an image inside my Widget?

Hi Seirei,

Have you tried utilizing a dynamic material instance to apply the changes directly to your material? Follow the steps here to set up a dynamic material instance, you should be able to make alterations as needed once you have this set up:

Yeah that’s what I’m using right now. I just wasn’t sure how to reference the instance and how to use it.

I got it working with this workflow:

  • In the widget designer I create an image object and place it
  • then I create a slate brush variable and use it in in the “bind” slot for the image itself
  • in a function I use the create dynamit material instance
  • promote that output to a variable so I can reference it later and use it in a “make SlateBrush” node
  • the output of that node goes into a “set” of the slate brush variable I use for the image

Do you think this is an acceptable workflow?

Currently I’m also wondering how you would reference a widget inside your game mode if it is placed inside a blueprint in your level.

Using event dispatchers seemed like the way to go, but since you need a target I’m not sure how you would acces it from inside the game mode. Basically I’m trying to get an exec ‘pulse’ from the game mode into the widget.

Thanks for your time! :slight_smile:

I believe you would want to use “get all widgets of class” to get the specific widgets you are looking for and access the information from there.

Hi ,

so I’ve been playing around with this for a bit, but I’m not sure how to get it to work.

How exactly do you use the “get all widgets of class” node? The output would be an array and it won’t let me use that for a “cast to…” or the bind node of an event dispatcher.
Using the “Get” from an array with the integer set to any number doesn’t work either. It won’t let me connect it to the event dispatcher binding and if I try to cast it it simply fails the cast.

All I want to do is to take one specific widget, no matter if it’s placed inside another blueprint or drawn as a hud, use it’s variables to controll stuff and be able to save them somewhere so I can restore them on my next startup. But the whole saving process is a completely different problem in itself.

Would it be possible for you to provide an example?

Like something very simple. A widget, drawn on the viewport with a slider in it that affects something in the level, like the rotation of a cube. And the ability to save it, so that on startup the cube has the same rotation and the slider is on the same position.

From there I just have to apply this to my example on a bigger scale, I hope.

Thanks anyways for the quick replys!

Hi Seirei,

I created a small sample to show what I mean. Please bear in mind this is an extremely limited and simplistic representation of the concepts behind Get all actors/widgets. Both work in the same way, the only difference being that one looks for blueprint actors and one looks for widgets. To get the save information, check out our save/load documentation here:

https://docs.unrealengine.com/latest/INT/Gameplay/SaveGame/Blueprints/index.html

project

Okay I’ve downloaded your scene and I think I get the idea now.

But for that I would need to completely redoo my blueprint workflow, because I currently use event dispatchers to send the values of my slider updates with their value into the level blueprint and use them on referenced actors in the level.

Your method seems way more modular, though, so thanks a lot! I’ll let you know if it worked.

I also took a look at the save/load documentation and I still have a tough time wrapping my head around it.

Saving and loading can be extremely difficult to work through. We have a video tutorial that makes use of the Save Game Object, you can check it out here:

https://www…com/watch?v=2vcqKH4ILHY

Hi ,

thanks for everything!

I finally got it to work and now I’m able to interact with objects using UMG. :slight_smile:

16 Sliders with on and off checkbox, 32 Variables, in the Widget and 32 in the Save Blueprint makes 64 per row and one is for saving and one is the loading.

So I have a total of 128 nodes that get and set different variables.

I feel there has to be a better way to exchange this data, but for the moment it works just fine and I’m happy that I finally know how to handle all of this.
Using the “Cast to” nodes also took a bit of getting used to.

So once again, thanks for the great support! :slight_smile: