最近魔改了一下ScrollBox,解决了之前一直很头疼的ScrollBar会占位置去挤ScrollBox里Content。
话不多说,很简单。首先找到源码SScrollBox,复制其.h,.cpp 写到一个新的类里;
修改两个函数 void ConstructVerticalLayout(); void ConstructHorizontalLayout();
void SCustomScrollBox::ConstructVerticalLayout()
{
TSharedPtr<SOverlay> PanelAndScrollbar;
this->ChildSlot
[
SAssignNew(PanelAndScrollbar,SOverlay)
+ SOverlay::Slot()
.Padding(FMargin(0.0f, 0.0f, 0.0f, 1.0f))
[
// Scroll panel that presents the scrolled content
ScrollPanel.ToSharedRef()
]
+ SOverlay::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Top)