Hi everyone,
I’m trying to active one object at a time between five, every time I press one button and save it.
But now I can only switch between two objects…
public class PlayerGun : MonoBehaviour {
public GameObject gun1;
public GameObject gun2;
public GameObject gun3;
public GameObject gun4;
public GameObject gun5;
public void Start () {
gun1.SetActive(true);
gun2.SetActive(false);
gun3.SetActive(false);
gun4.SetActive(false);
gun5.SetActive(false);
if (PlayerPrefs.HasKey("guns")){
if(PlayerPrefs.GetInt("guns") == 1) {
gun1.SetActive(false);
gun2.SetActive(true);
gun3.SetActive(false);
gun4.SetActive(false);
gun5.SetActive(false);
}
else
{
gun1.SetActive(false);
gun2.SetActive(true);
gun3.SetActive(false);
gun4.SetActive(false);
gun5.SetActive(false);
}
}
}
public void Upgradebuttom() {
PlayerPrefs.SetInt ("guns", 1);
gun1.SetActive(false);
gun2.SetActive(true);
gun3.SetActive(false);
gun4.SetActive(false);
gun5.SetActive(false);
}
public void Update () {
}
}