I wanted to save what the player bought in the store and then, when he starts the game again, there will be everything he bought before
There is all my code
Need help plssssss
public class ChangeSkin : MonoBehaviour
{
public GameObject ShopUI;
public GameObject BallShapesUI;
public GameObject ShapeBallCurrentUI;
public GameObject ShapeCubeUI;
public GameObject ShapeCubeBuyUI;
public GameObject ShapeCubeCurrentUI;
public Text ShapeCubeBuyText;
public int BuyCube = 0;
public int BuyStar = 0;
public GameObject ShapeStarUI;
public GameObject ShapeStarBuyUI;
public GameObject ShapeStarCurrentUI;
public Text ShapeStarBuyText;
public ShopMain sp;
public bool isActive = false;
public void Start(){
sp.GetComponent<ShopMain>();
}
public bool actived = false;
public void UnlockShape(){
float coins = PlayerPrefs.GetFloat("coins");
if(EventSystem.current.currentSelectedGameObject.name == "BuyStar" && isActive == false){
isActive = true;
if(){
ShapeStarCurrentUI.SetActive(true); //This is the Select btn
ShapeStarBuyUI.SetActive(false); //This is the Unlock btn
}
else{
if(coins >= 250){
coins = coins - 250;
PlayerPrefs.SetFloat("coins", coins);
ShapeStarCurrentUI.SetActive(true);
ShapeStarBuyUI.SetActive(false);
}else{
ShapeStarBuyText.color = new Color32(255,0,0,255);
ShapeStarBuyText.transform.localScale += new Vector3(.2f,.2f,1);
StartCoroutine(timerStar());
}
}
}
else if(EventSystem.current.currentSelectedGameObject.name == "BuyCube" && isActive == false)
{
isActive = true;
if(){
ShapeCubeCurrentUI.SetActive(true); //This is the Select btn
ShapeCubeBuyUI.SetActive(false); //This is the Unlock btn
}
else{
if(coins >= 0.1){
coins = coins - 0.1f;
PlayerPrefs.SetFloat("coins", coins);
ShapeCubeCurrentUI.SetActive(true);
ShapeCubeBuyUI.SetActive(false);
}else{
ShapeCubeBuyText.color = new Color32(255,0,0,255);
ShapeCubeBuyText.transform.localScale += new Vector3(.2f,.2f,1);
StartCoroutine(timerCube());
}
}
}
}
IEnumerator timerStar(){
yield return new WaitForSeconds(0.5f);
ShapeStarBuyText.color = new Color32(255,255,0,255);
ShapeStarBuyText.transform.localScale -= new Vector3(.2f,.2f,1);
isActive = false;
}
IEnumerator timerCube(){
yield return new WaitForSeconds(0.5f);
ShapeCubeBuyText.color = new Color32(255,255,0,255);
ShapeCubeBuyText.transform.localScale -= new Vector3(.2f,.2f,1);
isActive = false;
}
public void ClickBallShapesUI(){
ShopUI.gameObject.GetComponent<Canvas>().enabled = false;
BallShapesUI.gameObject.GetComponent<Canvas>().enabled = true;
}
public void ShopMenu(){
ShopUI.gameObject.GetComponent<Canvas>().enabled = true;
BallShapesUI.gameObject.GetComponent<Canvas>().enabled = false;
}
}