The item button framework

Before we link our items to the shop, we will first need to create a framework in which the items are placed in the shop. What we would like to do is create a button for each item that the shop owner sells but, in order to make the interface scalable in such a way that NPCs can hold different selectable items, it would be wise to create a Scroll Box framework that holds a single button with a default value for the item's text/description. We can then dynamically draw the button for as many items as the shop owner carries, as well as dynamically draw the text on each button.

To do this, we must first create a Widget Blueprint by navigating to Content | Blueprints | UI and call it Item:

The item button framework

Open Item. Since we are going to make the items clickable, we will program a button. To make the button, all that we will need is the button itself and text for the button; we will not need a Canvas Panel because we will eventually be adding this button to the Scroll Box of our shop. So, from the Hierarchy tab, delete the Canvas Panel, and drag a button from Palette. We will name this button, Button_Item:

The item button framework

Finally, we will place a Text Block in the button that we just created and name it TextBlock_Item:

The item button framework

Once done, navigate to Details | Content, and create a binding for the text in the Text Block. This will automatically open the graph with a Get Text function:

The item button framework

Create a new Item variable of the Text type:

The item button framework

Drag the Item variable into the graph, select Get to drop in a getter for the Item variable, and then link it to the Return Value pin of ReturnNode:

The item button framework
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.12.186