I want to custom a scrollbox ,but I can not get the size of my scrollbox and the widget I put in it, I guess "I just want to get the size of a widget " that mey be a simple question, please! who can help me? and forgive my bad english.
To do this, you can use UUserWidget::SetDesiredSizeInViewport function:
UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category="User Interface|Viewport") void SetDesiredSizeInViewport (FVector2D Size)
Hope this helped!
Thinks , do you mean that get the size manually? can I get it dynamic in the running time? I hava extended the scrollbox, I want to get the size of the widget added in it.
I may have found a way to get the size of a widget but its a little long winded to get there. Basically put your widget within a container, like a vertical or horizontal box. Make that container a variable so you can get it’s size.
I hope this helps
yes! I think it works , I find only canvas solt can get it
s childrens size, thanks.
this works perfect
Best way in cpp is
Or in BPs :
I cannot open the BP link
Another way, one that worked best for me, was to use the “Get Scroll Offset Of End” node from my scrollbox and use that as a clamp on the offset I applied via my input.
Input * scrollSpeed + GetScrollOffset (current offset) → Clamped between 0 (top of scrollbox) and GetScrollOffsetOfEnd (end of scrollbox) → pipe return into SetScrollOffset node.
Blueprint : Get Cached Geometry (returns a Geometry), Get Local Size (takes in a geometry) …
Really nice one, thanks