I created a custom widget then placed it inside a Canvas. I use Size To Content for the widget. Then I need to get the size of the widget to calculate new position in the Canvas (inside a viewport) whenever it is shown.
However, if I use GetSize from the UCanvasPanelSlot for the widget, I got the value that specified in the Details (Class Default) panel (Size X and Size Y). The size of the widget, of course changed dynamically. But the GetSize() value always return the same value.
How could I get the UCanvasPanelSlotSize that is Size To Content?
Thank you in advance for all you help.
Never mind. Apparently the Geometry in NativeTick, stored the runtime data of the widget. It knows what its current size. So, each time it has different size, just update the size variable (custom variable) inside the widget and use it whenever needed.
how to do that?how to get the geometry data?I can’t find it.
update size variable?
Alternatively you can try to get the UCanvasPanelSlot (if you’re using a Widget with an UCanvasPanelSlot) to get the size:
You can see the kind of PanelSlot of an widget, when selecting it in the Designer Tab on the Details Panel:
You can get it like this:
Zcience thanks. that solved