Basically my Player.prefs control my players Coins and lives it works flawlessly on unity and in a windows build but when i convert it into android id doesn’t work at all not even in the same scene
i really do not understand where im going wrong
heres my life manager
public class LivesManager : MonoBehaviour {
public int StartingLives;
private int LifeCounter;
private LivesManager LifeSystem;
public GameObject Timer;
public Transform SpawnPoint;
private Text thetext;
void Start()
{
LifeSystem = FindObjectOfType<LivesManager>();
thetext = GetComponent<Text>();
if (PlayerPrefs.GetInt("life") <= 0)
{
StartCoroutine(WaitTime());
}
}
void Update()
{
if (PlayerPrefs.HasKey("life"))
{
LifeCounter = PlayerPrefs.GetInt("life");
}
thetext.text = "x " + LifeCounter;
}
public void GiveLife5()
{
LifeCounter += 5;
PlayerPrefs.SetInt("life", LifeCounter);
PlayerPrefs.Save();
}
public void GiveLife()
{
LifeCounter++;
PlayerPrefs.SetInt("life", LifeCounter);
PlayerPrefs.Save();
}
public void Takelife()
{
LifeCounter--;
PlayerPrefs.SetInt("life", LifeCounter);
PlayerPrefs.Save();
}
public void OnButtonPressChallenge()
{
if (LifeCounter > 3)
{
Debug.Log("Nope");
return;
}
Application.LoadLevel("ChallengeMode");
}
public void OnButtonPressStore()
{
Application.LoadLevel("Store");
}
public void OnButtonPressMission()
{
Application.LoadLevel("Zone1");
}
This is accessed by multiple scripts including this welcome button which adds 5 lives.
public class Welcome : MonoBehaviour {
private int Clicked;
public GameObject Button;
private LivesManager LifeSystem;
void Start()
{
LifeSystem = FindObjectOfType<LivesManager>();
if (PlayerPrefs.HasKey("welcome"))
{
Clicked = PlayerPrefs.GetInt("welcome");
}
}
public void OnButtonPress()
{
Debug.Log("Welcome");
LifeSystem.GiveLife5();
Clicked++;
PlayerPrefs.SetInt("welcome", Clicked);
PlayerPrefs.Save();
}
void Update()
{
if (Clicked == 1)
{
Debug.Log("goneforever");
Destroy(Button);
}
}
}