Question by
The_Ginge_Gamer · May 12, 2020 at 05:46 PM ·
buttonfunctionvoid
void functions not showing in OnClick()
Hi, I have been trying to create a shop system in my game using a series of buttons and functions. However, when I try to attach any functions relating to "blue" they do not appear. This is strange as the script for the blue texture is the same as the red but with different names, (the red functions are appearing as expected). Whatever I do I cannot work out how to make them appear. Please help
RedBought = PlayerPrefs.GetString("RedBought", "no");
if (RedBought == "no")
{
NotEnoughDiamonds.SetActive(false);
RedBuy.SetActive(true);
RedEquip.SetActive(false);
RedEquipped.SetActive(false);
}
else
{
IsRedEquipped = PlayerPrefs.GetString("IsRedEquipped", "no");
if (IsRedEquipped == "no")
{
NotEnoughDiamonds.SetActive(false);
RedBuy.SetActive(false);
RedEquip.SetActive(true);
RedEquipped.SetActive(false);
}
else
{
NotEnoughDiamonds.SetActive(false);
RedBuy.SetActive(false);
RedEquip.SetActive(false);
RedEquipped.SetActive(true);
}
}
BlueBought = PlayerPrefs.GetString("BlueBought", "no");
if (BlueBought == "no")
{
NotEnoughDiamonds.SetActive(false);
BlueBuy.SetActive(true);
BlueEquip.SetActive(false);
BlueEquipped.SetActive(false);
}
else
{
IsBlueEquipped = PlayerPrefs.GetString("IsBlueEquipped", "no");
if (IsBlueEquipped == "no")
{
NotEnoughDiamonds.SetActive(false);
BlueBuy.SetActive(false);
BlueEquip.SetActive(true);
BlueEquipped.SetActive(false);
}
else
{
NotEnoughDiamonds.SetActive(false);
BlueBuy.SetActive(false);
BlueEquip.SetActive(false);
BlueEquipped.SetActive(true);
}
}
}
public void buyRed()
{
numberofdiamonds = PlayerPrefs.GetInt("Diamonds", 0);
if (numberofdiamonds > 50)
{
PlayerPrefs.SetString("RedBought", "yes");
numberofdiamonds = numberofdiamonds - 50;
PlayerPrefs.SetInt("Diamonds", numberofdiamonds);
}
else
{
NotEnoughDiamonds.SetActive(true);
StartCoroutine(Wait(2.0f));
NotEnoughDiamonds.SetActive(false);
}
}
public void equipRed()
{
PlayerPrefs.SetString("IsRedEquipped", "yes");
PlayerPrefs.SetString("Texture", "Red");
}
public void resetRed()
{
PlayerPrefs.SetString("Bought", "no");
}
public void buyBlue()
{
numberofdiamonds = PlayerPrefs.GetInt("Diamonds", 0);
if (numberofdiamonds > 50)
{
PlayerPrefs.SetString("BlueBought", "yes");
numberofdiamonds = numberofdiamonds - 50;
PlayerPrefs.SetInt("Diamonds", numberofdiamonds);
}
else
{
NotEnoughDiamonds.SetActive(true);
StartCoroutine(Wait(2.0f));
NotEnoughDiamonds.SetActive(false);
}
}
public void EquipBlue()
{
PlayerPrefs.SetString("IsBlueEquipped", "yes");
PlayerPrefs.SetString("Texture", "Blue");
}
public void resetBlue()
{
PlayerPrefs.SetString("Bought", "no");
}
public IEnumerator Wait(float delayInSecs)
{
yield return new WaitForSeconds(delayInSecs);
}
}
Thank You in advance
Comment
Your answer
Follow this Question
Related Questions
How I can change listener via script? 1 Answer
Not finding a class in inspector (Easy) 0 Answers
What go inside the brackets in voids? 1 Answer
In void bool dont changing 1 Answer