This final bonus tutorial shows you how to create a coin shop where players can purchase different player skins using the coins they've collected.
1 Creating the Shop Scene
- Duplicate the Start scene (Ctrl+D)
- Rename it to "Coin Shop"
- Change the title text to "Shop"
- Anchor the title to the top center
2 Creating the Item List
- Create an empty GameObject called "List"
- Add Horizontal Layout Group component
- Set Spacing to 20
- Set Child Alignment to Upper Center
- Stretch the RectTransform to fill the width
- Uncheck Child Force Expand (Width)
Unity provides Horizontal, Vertical, and Grid Layout Groups for automatic UI arrangement. Choose based on your shop design.
3 Creating Shop Items
Item Structure
- Add UI → Image inside the List
- Set a color (e.g., Blue) - this represents the skin
- Name it "Blue"
- Copy the coin UI from your level and paste it as a child
- Anchor to bottom-right, scale to 0.7
- Change the price text to "10"
- Remove the Script Machine from the price text (we'll handle it differently)
Item Variables
Add a Script Machine to the item with these Object Variables:
- ID (String): "blue" - unique identifier for saving
- Color (Color): The actual color value
- Price (Integer): 10
- Price Text (GameObject): Reference to the text object
4 Item Configuration Graph
Create a graph called "Item Graph" with On Start logic:
Setting the Color
- Add Image Set Color
- Connect your Color variable
Setting the Price Text
- Add Set Text
- Convert Price (Integer) to String
- Use Price Text variable as the target
5 Creating Multiple Items
- Duplicate the Blue item
- Create Orange (price 20), Green (price 25), Red (price 0)
- Update each item's ID, Color, and Price variables
- Red is the default free skin
6 Player Skin Variable
- Go to Saved Variables
- Add "Player Skin" (Color type)
- Set default to Red
Applying Skin to Player
- Open the Player prefab graph
- On Start: Get the Player Skin saved variable
- Add Mesh Renderer Get Material
- Add Material Set Color
- Connect the saved color
7 Purchase Logic
Add On Pointer Click event to the item graph:
Check if Already Purchased
- Add Get Saved Variable (using ID as the name)
- Set Fallback to False (for items not yet purchased)
- Add If unit
If Already Purchased (True)
- Just select the skin (set Player Skin variable)
- Load the first level (build index 1)
If Not Purchased (False)
- Check if coins >= price
- If yes:
- Subtract price from Coins
- Save the purchase (set ID variable to True)
- Set Player Skin to this color
- Load the first level
- If no: Do nothing (or show an error)
Always use the Fallback option when getting saved variables that might not exist yet. This prevents errors when checking for unpurchased items.
8 Hiding Price for Owned Items
In the configuration (On Start), after checking if purchased:
- If the item is already purchased:
- Get the Price Text's parent (the coin icon group)
- Set Active to False
9 Setting Default Owned Items
- Go to Saved Variables
- Add "red" (Boolean) = True
- This marks the red skin as already owned
Complete Shop Flow
- Player opens shop
- Owned items show without price
- Click an owned item → Select skin and start game
- Click an unowned item:
- Have enough coins → Purchase, select, and start game
- Not enough coins → Nothing happens
Extending the Shop
Ideas for further development:
- Show an error message when coins are insufficient
- Highlight the currently selected skin
- Add a "Back" button to return to the main menu
- Display current coin count in the shop
- Add more customization options (meshes, particles, etc.)
Series Complete!
Congratulations on completing the Visual Scripting series! You've learned to build a complete game with multiple levels, UI, animations, and a coin shop - all without writing code.