Ok so i have this bad script but it works fine the most of the time at least ,the thing is that the public void GoldA() its not working properly i have tried everything but every time it enters this void the GoldLock become 0 i put a text so ican see the number of the goldlock before enter the “if” and in my screen it says 15 when i enter to GoldLock become 0 the funny part is i used the same tactic for all the other voids but they work just fine the only difference is that the playerpref is set in another scene
i try to change the name o the playerpref …didnt work
i double check everything they look fine
i know that my code is bad but it used to work fine
my english is not my native language i hope you will understand what im trying to say !
anyway thanks for your time!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ColourSetA : MonoBehaviour
{
public GameObject Green;
public GameObject Black;
public GameObject White;
public GameObject Blue;
public GameObject Pink;
public GameObject Red;
public GameObject Gold;
public GameObject WhitePlay;
public GameObject BlackPlay;
public GameObject GreenPlay;
public GameObject BluePlay;
public GameObject PinkPlay;
public GameObject RedPlay;
public GameObject GoldPlay;
public GameObject BlackLockButton;
public GameObject WhiteLockButton;
public GameObject BlueLockButton;
public GameObject PinkLockButton;
public GameObject RedLockButton;
public GameObject GoldLockButton;
public GameObject PriceBlack;
public GameObject PriceWhite;
public GameObject PriceBlue;
public GameObject PricePink;
public GameObject PriceRed;
public GameObject PriceGold;
private int WhiteLock;
private int BlackLock;
private int BlueLock;
private int PinkLock;
private int RedLock;
private float GoldLock;
public Text debug;
void Update()
{
GoldLock = PlayerPrefs.GetInt("Fgold");
RedLock = PlayerPrefs.GetInt("Redlock");
BlueLock = PlayerPrefs.GetInt("Bluelock");
BlackLock = PlayerPrefs.GetInt("blacklock");
WhiteLock = PlayerPrefs.GetInt("Whitelock");
PinkLock = PlayerPrefs.GetInt("Pinklock");
if (GoldLock > 0)
{
PriceGold.SetActive(false);
}
if (GoldLock <= 0)
{
PriceGold.SetActive(true);
}
if (BlueLock > 0)
{
PriceBlue.SetActive(false);
}
if (BlueLock <= 0)
{
PriceBlue.SetActive(true);
}
if (BlackLock <= 0)
{
PriceBlack.SetActive(true);
}
if (BlackLock > 0)
{
PriceBlack.SetActive(false);
}
if (WhiteLock <= 0)
{
PriceWhite.SetActive(true);
}
if (WhiteLock > 0)
{
PriceWhite.SetActive(false);
}
if (PinkLock > 0)
{
PricePink.SetActive(false);
}
if (PinkLock <= 0)
{
PricePink.SetActive(true);
}
if (RedLock > 0)
{
PriceRed.SetActive(false);
}
if (RedLock <= 0)
{
PriceRed.SetActive(true);
}
}
public void GreenA()
{
Gold.SetActive(false);
Red.SetActive(false);
Pink.SetActive(false);
Blue.SetActive(false);
Green.SetActive(true);
Black.SetActive(false);
White.SetActive(false);
WhitePlay.SetActive(false);
BlackPlay.SetActive(false);
GreenPlay.SetActive(true);
BluePlay.SetActive(false);
PinkPlay.SetActive(false);
RedPlay.SetActive(false);
GoldPlay.SetActive(false);
WhiteLockButton.SetActive(false);
RedLockButton.SetActive(false);
BlackLockButton.SetActive(false);
PinkLockButton.SetActive(false);
BlueLockButton.SetActive(false);
GoldLockButton.SetActive(false);
}
public void BlackA()
{
Gold.SetActive(false);
Red.SetActive(false);
Pink.SetActive(false);
Blue.SetActive(false);
Green.SetActive(false);
Black.SetActive(true);
White.SetActive(false);
WhitePlay.SetActive(false);
BlackPlay.SetActive(true);
GreenPlay.SetActive(false);
BluePlay.SetActive(false);
PinkPlay.SetActive(false);
RedPlay.SetActive(false);
GoldPlay.SetActive(false);
WhiteLockButton.SetActive(false);
RedLockButton.SetActive(false);
GoldLockButton.SetActive(false);
PinkLockButton.SetActive(false);
BlueLockButton.SetActive(false);
BlackLock = PlayerPrefs.GetInt("blacklock");
if (BlackLock <= 0)
{
BlackLockButton.SetActive(true);
BlackPlay.SetActive(false);
}
if (BlackLock > 0)
{
BlackLockButton.SetActive(false);
}
}
public void WhiteA()
{
Gold.SetActive(false);
Red.SetActive(false);
Pink.SetActive(false);
Blue.SetActive(false);
Green.SetActive(false);
Black.SetActive(false);
White.SetActive(true);
WhitePlay.SetActive(true);
BlackPlay.SetActive(false);
GreenPlay.SetActive(false);
BluePlay.SetActive(false);
PinkPlay.SetActive(false);
RedPlay.SetActive(false);
GoldPlay.SetActive(false);
WhiteLockButton.SetActive(false);
RedLockButton.SetActive(false);
BlackLockButton.SetActive(false);
PinkLockButton.SetActive(false);
BlueLockButton.SetActive(false);
GoldLock = PlayerPrefs.GetInt("Whitelock");
if (WhiteLock <= 0)
{
WhiteLockButton.SetActive(true);
WhitePlay.SetActive(false);
}
if (WhiteLock > 0)
{
WhiteLockButton.SetActive(false);
}
}
public void BlueA()
{
Gold.SetActive(false);
Red.SetActive(false);
Pink.SetActive(false);
Blue.SetActive(true);
Green.SetActive(false);
Black.SetActive(false);
White.SetActive(false);
WhitePlay.SetActive(false);
BlackPlay.SetActive(false);
GreenPlay.SetActive(false);
BluePlay.SetActive(true);
PinkPlay.SetActive(false);
RedPlay.SetActive(false);
GoldPlay.SetActive(false);
WhiteLockButton.SetActive(false);
RedLockButton.SetActive(false);
BlackLockButton.SetActive(false);
PinkLockButton.SetActive(false);
GoldLockButton.SetActive(false);
BlueLock = PlayerPrefs.GetInt("Bluelock");
if (BlueLock <= 0)
{
BlueLockButton.SetActive(true);
BluePlay.SetActive(false);
}
if (BlueLock > 0)
{
BlueLockButton.SetActive(false);
}
}
public void PinkA()
{
Gold.SetActive(false);
Red.SetActive(false);
Pink.SetActive(true);
Blue.SetActive(false);
Green.SetActive(false);
Black.SetActive(false);
White.SetActive(false);
WhitePlay.SetActive(false);
BlackPlay.SetActive(false);
GreenPlay.SetActive(false);
BluePlay.SetActive(false);
PinkPlay.SetActive(true);
RedPlay.SetActive(false);
GoldPlay.SetActive(false);
WhiteLockButton.SetActive(false);
RedLockButton.SetActive(false);
BlackLockButton.SetActive(false);
GoldLockButton.SetActive(false);
BlueLockButton.SetActive(false);
PinkLock = PlayerPrefs.GetInt("Pinklock");
if (PinkLock <= 0)
{
PinkLockButton.SetActive(true);
PinkPlay.SetActive(false);
}
if (PinkLock > 0)
{
PinkLockButton.SetActive(false);
}
}
public void RedA()
{
Gold.SetActive(false);
Red.SetActive(true);
Pink.SetActive(false);
Blue.SetActive(false);
Green.SetActive(false);
Black.SetActive(false);
White.SetActive(false);
WhitePlay.SetActive(false);
BlackPlay.SetActive(false);
GreenPlay.SetActive(false);
BluePlay.SetActive(false);
PinkPlay.SetActive(false);
RedPlay.SetActive(true);
GoldPlay.SetActive(false);
WhiteLockButton.SetActive(false);
GoldLockButton.SetActive(false);
BlackLockButton.SetActive(false);
PinkLockButton.SetActive(false);
BlueLockButton.SetActive(false);
PinkLock = PlayerPrefs.GetInt("Redlock");
if (RedLock <= 0)
{
RedLockButton.SetActive(true);
RedPlay.SetActive(false);
}
if (RedLock > 0)
{
RedLockButton.SetActive(false);
}
}
public void GoldA()
{
Gold.SetActive(true);
Red.SetActive(false);
Pink.SetActive(false);
Blue.SetActive(false);
Green.SetActive(false);
Black.SetActive(false);
White.SetActive(false);
WhitePlay.SetActive(false);
BlackPlay.SetActive(false);
GreenPlay.SetActive(false);
BluePlay.SetActive(false);
PinkPlay.SetActive(false);
RedPlay.SetActive(false);
GoldPlay.SetActive(true);
WhiteLockButton.SetActive(false);
RedLockButton.SetActive(false);
BlackLockButton.SetActive(false);
PinkLockButton.SetActive(false);
BlueLockButton.SetActive(false);
GoldLock = PlayerPrefs.GetInt("Fgold");
debug.text = GoldLock.ToString();
if (GoldLock <= 0)
{
GoldLockButton.SetActive(true);
GoldPlay.SetActive(false);
Debug.Log("why you are here again");
}
if (GoldLock > 0)
{
GoldLockButton.SetActive(false);
}
}
}