
This post contains all the code that’s been written in the YouTube video.
You can read it at your own pace, although watching the video prior to looking at this code example is recommended.
ShopManagerScript.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ShopManagerScript : MonoBehaviour {
[SerializeField]
private Transform[] shopBtns;
public Text CoinsTxt, SelectedItemTxt;
public Color SelectedColor, NonSelectedColor;
private int prevSelectedIndex;
private void Start()
{
for (int i = 0; i < shopBtns.Length; i++)
{
shopBtns[i].GetChild(0).GetComponent<Text>().text = Inventory.Items[i].Name;
}
UpdateUI();
}
public void BuyOrSelectItem(int index)
{
if (Inventory.Items[index].Bought)
Inventory.Instance.SelectItem(index);
else
Inventory.Instance.BuyItem(index);
UpdateUI();
}
private void UpdateUI()
{
CoinsTxt.text = "Coins: " + Inventory.Coins.ToString();
SelectedItemTxt.text = Inventory.Items[Inventory.SelectedItemIndex].Name;
shopBtns[prevSelectedIndex].GetComponent<Image>().color = NonSelectedColor;
shopBtns[Inventory.SelectedItemIndex].GetComponent<Image>().color = SelectedColor;
prevSelectedIndex = Inventory.SelectedItemIndex;
}
}

hy mr resocoder. would you help?
i have big a problem in my game.. i have many scenes, many characters and a scene shop. but how to declare the character in the shop to apply in many scenes when i selected a character in the scene shop..
please help me
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
Thanks for sharing. I read many of your blog posts, cool, your blog is very good. https://accounts.binance.com/en/register-person?ref=V3MG69RO
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article. https://www.binance.info/cs/register?ref=S5H7X3LP
Your point of view caught my eye and was very interesting. Thanks. I have a question for you. https://accounts.binance.info/lv/register?ref=SMUBFN5I