How to scale UMG via mouse wheel?

How can scale a UMG via mouse wheel up/down?

You can set up an event which sets (add or subtract) values from the Render Transform (break the struct and you find the scale) of the Main Canvas in your UMG widget.

Then you can trigger that event with the Mouse Wheel Down and Mouse Wheel Up Event.

Hi CppCode

You will need to set up your widget to fire custom events, I labeled them as Increase Size and Decrease size. I also created 3 float variables, One for changing the Scale’s X value, One for changing the Scale’s Y value, and one that controls by how much the size will increase and decrease with the turn of the mouse wheel. With these variables set up I simply set the new X and Y values to be added or subtracted by the custom value and set the Render Scale with the new values.

Next You will have to go to your character BP, and set up your widget to render in the view-port. Then Use the Mouse Wheel Up and Down event to call the custom events Increase Size and Decrease size.

Hopefully this helps, and good luck scripting!

Widget BP

Character BP

1 Like

Thank you. works well。