首页 > 其他 > 详细

UMG ScrollBox Reverse

时间:2021-05-11 22:18:44      阅读:30      评论:0      收藏:0      [点我收藏+]

在ScrollBox 对应的panel中, 修改 OnArrangeChildren 方法, 开放一个参数给界面配置

void SScrollPanelExt::OnArrangeChildren(const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren) const
{
    float CurChildOffset = -PhysicalOffset;

    if (bReverseDirection) // 差异就在这一段里
    {
        for (int32 SlotIndex = Children.Num() - 1; SlotIndex >= 0; --SlotIndex)
        {
            const SScrollBoxExt::FSlot& ThisSlot = Children[SlotIndex];
            const EVisibility ChildVisibility = ThisSlot.GetWidget()->GetVisibility();

            if (ChildVisibility != EVisibility::Collapsed)
            {
                if (Orientation == Orient_Vertical)
                {
                    CurChildOffset = ArrangeChildVerticalAndReturnOffset(AllottedGeometry, ArrangedChildren, ThisSlot, CurChildOffset);
                }
                else
                {
                    CurChildOffset = ArrangeChildHorizontalAndReturnOffset(AllottedGeometry, ArrangedChildren, ThisSlot, CurChildOffset);
                }
            }
        }
    }
    else {
        for (int32 SlotIndex = 0; SlotIndex < Children.Num(); ++SlotIndex)
        {
            const SScrollBoxExt::FSlot& ThisSlot = Children[SlotIndex];
            const EVisibility ChildVisibility = ThisSlot.GetWidget()->GetVisibility();

            if (ChildVisibility != EVisibility::Collapsed)
            {
                if (Orientation == Orient_Vertical)
                {
                    CurChildOffset = ArrangeChildVerticalAndReturnOffset(AllottedGeometry, ArrangedChildren, ThisSlot, CurChildOffset);
                }
                else
                {
                    CurChildOffset = ArrangeChildHorizontalAndReturnOffset(AllottedGeometry, ArrangedChildren, ThisSlot, CurChildOffset);
                }
            }
        }
    }
}

即可简单的将上下左右反转。

UMG ScrollBox Reverse

原文:https://www.cnblogs.com/Fivee/p/14756651.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!