# Verse UI Logic/Flow Issue

**URL:** <https://forums.unrealengine.com/t/verse-ui-logic-flow-issue/2641958>\
**Category:** Programming & Scripting\
**Tags:** flow-control, User-Interface, unreal-editor-for-fortnite, fortnite-creative, UI, question, fortnite, verse\
**Created:** [August 14, 2025, 6:19pm UTC](https://forums.unrealengine.com/t/verse-ui-logic-flow-issue/2641958 "2025-08-14T18:19:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![WayWARD8](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@WayWARD8](https://forums.unrealengine.com/u/WayWARD8)\
**Post date:** [August 14, 2025, 6:19pm UTC](https://forums.unrealengine.com/t/verse-ui-logic-flow-issue/2641958/1 "2025-08-14T18:19:28Z")

</div>

I’m attempting to draw some UI to the screen that will represent a shop window to buy upgrades.

To do so I call a function that draws UI (ShowShopUI); this function initialises three discrete arrays of type stack\_box. Each element of these arrays represents an item card in the shop, comprising a string, icon, price and buy button.

Within ShowShopUI another function is called (CreateShopScreen). This function is passed the no initialised arrays and is responsible for adding the relvant content to a canvas and returning that canvas to be drawn on-screen.

Things work as expected when only a single array of item cards are passed to CreateShopScreen:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/1/9/419de77b9bcf281b3abf26284d658e01d045be2d.jpeg)  
There is a section title, and two item cards.

However, when I attempt to add two further arrays of item cards, the flow/logic falls over and I’m just not sure why. Frustratingly, the titles of the sections work and are added in a vertical stack but all of the item cards are grouped together with the last array and appear beneath the last section, if that makes sense:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/f/2/ff261a6473dc9c024a45db43065cdfddd09467b4.jpeg)

Can anyone help point me in the right direction to resolve this?

Code below:

```auto
shop_canvas := class():
    var ShopCanvas : canvas = canvas{}
    var OverlayContainer : overlay = overlay{}
    ShopBackgroundImage : texture_block = texture_block{DefaultImage := shop_background, DefaultDesiredSize := vector2{X:=1000.0, Y:=1100.0}}
    var RootStackbox : stack_box = stack_box {Orientation := orientation.Vertical}
    WhiteColor : color = MakeColorFromSRGB(1.0, 1.0, 1.0)

CreateShopScreen<public>(Stack_S0 : []stack_box, Stack_S1 : []stack_box, Stack_S2 : []stack_box, ShopManager : shop_manager, ShopLevelText : overlay) : canvas =
        
        # Build the entire UI
        ShopCanvas.AddWidget(canvas_slot{
            Widget := OverlayContainer,
            Anchors := anchors{Minimum := vector2{X := 0.5, Y := 0.5}, Maximum := vector2{X := 0.5, Y := 0.5}},
            Offsets := margin{Left := 0.0, Top := 0.0, Right := 1000.0, Bottom := 1100.0},
            Alignment := vector2{X := 0.5, Y := 0.5},
            SizeToContent := false,
            ZOrder := 0
            })
        OverlayContainer.AddWidget(overlay_slot{
            Widget := ShopBackgroundImage,
            Padding := margin{Left := 0.0, Top := 0.0, Right := 0.0, Bottom := 0.0},
            HorizontalAlignment := horizontal_alignment.Fill,
            VerticalAlignment := vertical_alignment.Fill
            })

        RootStackbox.AddWidget(stack_box_slot{
            Widget := AddStackboxToUI(Stack_S0, "Section 0 Upgrades")#LevelStackbox0_Outer,
            Padding := margin{Left := 0.0, Top := 0.0, Right := 0.0, Bottom := 0.0}
            })

        # RootStackbox.AddWidget(stack_box_slot{
        # Widget := AddStackboxToUI(Stack_S1, "Section 1 Upgrades")#LevelStackbox1_Outer,
        # Padding := margin{Left := 0.0, Top := 0.0, Right := 0.0, Bottom := 0.0}
        # })

        # RootStackbox.AddWidget(stack_box_slot{
        # Widget := AddStackboxToUI(Stack_S2, "Section 2 Upgrades")#LevelStackbox2_Outer,
        # Padding := margin{Left := 0.0, Top := 0.0, Right := 0.0, Bottom := 0.0}
        # })

        OverlayContainer.AddWidget(overlay_slot{
            Widget := RootStackbox,
            Padding := margin{Left := 0.0, Top := 0.0, Right := 0.0, Bottom := 0.0},
            HorizontalAlignment := horizontal_alignment.Center,
            VerticalAlignment := vertical_alignment.Center 
        })
        # Exit button
        ExitButton := button_quiet {DefaultText := StringToMessage("Exit")}
        OverlayContainer.AddWidget(overlay_slot{
                Widget := ExitButton,
                Padding := margin{Left := 0.0, Top := 30.0, Right := 30.0, Bottom := 0.0},
                HorizontalAlignment := horizontal_alignment.Right,
                VerticalAlignment := vertical_alignment.Top
            })
        # Button subscriptions
        ExitButton.OnClick().Subscribe(ExitShop)
        return ShopCanvas

AddStackboxToUI(Stackbox : []stack_box, SectionString : string) : stack_box =
    var LevelStackbox : stack_box = stack_box{Orientation := orientation.Vertical}
    var LevelStackbox_Inner : stack_box = stack_box{Orientation := orientation.Horizontal}

    for (Index -> ItemStackbox : Stackbox):
        LevelStackbox_Inner.AddWidget(stack_box_slot{
            Widget := ItemStackbox,
            Padding := margin{Left := 20.0, Top := 10.0, Right := 20.0, Bottom := 10.0},
            HorizontalAlignment := horizontal_alignment.Center,
            VerticalAlignment := vertical_alignment.Center
        })

    LevelStackbox.AddWidget(stack_box_slot{
        Widget := text_block{ DefaultText := StringToMessage(SectionString), DefaultTextColor := WhiteColor},
        Padding := margin{Left := 0.0, Top := 15.0, Right := 0.0, Bottom := 15.0},
        HorizontalAlignment := horizontal_alignment.Center,
        VerticalAlignment := vertical_alignment.Center
    })

    LevelStackbox.AddWidget(stack_box_slot{
        Widget := LevelStackbox_Inner,
        Padding := margin{Left := 0.0, Top := 0.0, Right := 0.0, Bottom := 0.0}
    })

    return LevelStackbox

```

---

<div class="post-metadata">

**Author:** ![Hicsy](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hicsy/32/1077500_2.png) [@Hicsy](https://forums.unrealengine.com/u/Hicsy)\
**Post date:** [August 16, 2025, 11:20am UTC](https://forums.unrealengine.com/t/verse-ui-logic-flow-issue/2641958/2 "2025-08-16T11:20:30Z")

</div>

Weird. Hopefully someone else can see what it happening better than myself…

I wonder if it’s flattening the 2x sequential layers of vertical stackbox when adding the `RootStackbox` slots to `OverlayContainer`.  
_Maybe it’s threading the function calls?_

* * *

Perhaps first just try shifting the 3x `RootStackbox.AddWidget()` calls until **after** all 3x `OverlayContainer.AddWidget()` calls?  
_(so the root is **already on the canvas overlay** BEFORE adding your sections to it)_

* * *

Otherwise, i’d next try manually wrapping each section in their own horizontal:

```verse
# Maybe try manually wrapping each call within their own Horiz box?:
OverlayContainer.AddWidget:
    stack_box:
        Orientation := orientation.Horizontal
        Slots := array:
            stack_box_slot:
                Widget := AddStackboxToUI(S0|S1|S2,"...")

```
