So I’ve managed to create a custom cursor material. The texture is of multiple cursors, so I thought it would be clever to cycle between them when I hover over a button. I cannot for the life of me figure out how to access material properties within a blue print. You can see what ive set up in my material: change the number, the cursor changes. Included is my attempt at changing the value of the cursor from a hover over a button.
Did you debug and check if the pins are actually firing all the way into the Set Scalar Parameter Value?
You have not connected the ‘Set Dyanamicmaterial Cursor’ node to anything. You should connect the Exit pin of ‘Create Dynamic Material Instance’ node to the Entry pin of that node. Then connect the Exit pin of ‘Set Dyanamicmaterial Cursor’ to branch.
BUT you are doing something terribly wrong here. You are creating a dynamic material instance in every tick. Thats not how you should do it. The creation of Dyanmic material instance should be done only once. SO move it to Construct event.
So everything before the ‘Branch’ node should be moved to Construct.
What you’re doing with that graph is just creating a new material every frame.
Like ~60 new materials every second and not applying them anywhere.
When you create a material instance, you must apply it to the target mesh.
Then you change the parameter value and your changes to the material will be visible. You never create a material instance every frame, no need for that.
Alright, so I’ve moved these things to the level blueprint, where the buttons themselves were being spawned…and I still can’t get the scalar parameter value inside of my cursor material to actually change. When I play the scene, the pin fires into the set scalar parameters node…but the cursor does not change. Any other way of talking to my material via a blueprint?
For anyone wanting the answer: I was using drawmaterial simple, inside a hud blueprint, called with an ‘eventreceivedrawhud.’ The reason my material was not updating was because the drawhud is something that happens every frame. So basically, I created a dynamic material instance variable inside the construction script of my player controller, as well as a float that was tied to the scalar parameter of my cursor. Inside my hud blueprint I then cast to the player controller, got those variables, and plugged them into the drawmaterial. In short, unreal is hard, nothing worked, and figuring it out is the best feeling in the world. Thanks everyone!