Im trying to do a group of buttons that expands and extends the more buttons you add. This will vary depending on the attack types a player has.
Should look someting like this, though with varying number of buttons:
Though when i add in buttons the button that should reveal the attack type buttons, starts going below. That is because the wrap box as you add more buttons to it, it just expands below, it never expands upwards.
You will need a canvas and anchor content to the bottom of the screen. Either in this widget or in this widget’s parent. Or is this already in an anchored canvas slot?
I was told to avoid canvas pannel and use grid whenever possible. And honestly i think thats a good tip, and i have been able to do everything i need.
Are you sure there’s no other way without using Canvas Pannel ?
Avoid canvas where it does not belong - it gets expensive when abused. But it performs one unique and important job no other widget can pull off - Anchoring. For a main UI, one would normally have a Master Widget with a single canvas where other User Widgets (like the menu you’re showing) live, anchored to screen edges with pixel offsets. This makes switching between resolutions and aspect ratios feasible.
I don’t think you can even measure the performance impact of a single canvas. You can definitely notice it of you have have 1000 inventory items and every single one of them sports a canvas…
In UE4 Canvas was the default root widget - lots of folk simply used it as is for everything, without knowing any better. This includes tutorials. Canvas has a bad rep, like ticking, and casting. All of them are simply indispensable in certain circumstances.
If you asked me, I’d say this is a perfect job for the misunderstood canvas.
If you wanted to do it manually, each time you populate the wrap box, wait for a Layout Pre Pass (or force one), get Desired Size, get Viewport Size and offset the widget’s position. Imho, that’s not worth the fuss… especially that canvas can also zOrder and do some extra bits.
yeah i considered calculating the position dynamically and updating it when the wrap box increases.
The issue with that is that the different resolutions, its quite confusing, because moving 50 px upwards in a different resolution is different. I think there was a node that did this automatically but i dont remember. Something about get scaled resolution something like that ughh, so much stuff to keep track, i alwways forget stuff-.