Quantcast
Channel: Questions in topic: "playerprefs"
Viewing all articles
Browse latest Browse all 1333

button and PlayerPrefs

$
0
0
i have 3 button i want when i click button 1, hide that button and show all button with PlayerPrefs, and when i click button 2, hide that button and show all button with PlayerPrefs i test my code but work with button 2 only void Start () { if (PlayerPrefs.GetInt("Button1") == 1){ object1.gameObject.SetActive (false); object2.gameObject.SetActive (true); } else if (PlayerPrefs.GetInt("Button1") == 0){ object1.gameObject.SetActive (false); object2.gameObject.SetActive (true); } if (PlayerPrefs.GetInt("Button2") == 1){ object2.gameObject.SetActive (false); object1.gameObject.SetActive (true); } else if (PlayerPrefs.GetInt("Button2") == 0){ object1.gameObject.SetActive (true); object2.gameObject.SetActive (true); } } public void whenclickbutton1(){ object2.gameObject.SetActive (true); PlayerPrefs.SetInt("Button1",1); PlayerPrefs.SetInt("Button2",0); PlayerPrefs.Save (); } public void whenclickbutton2(){ object1.gameObject.SetActive (true); PlayerPrefs.SetInt("Button2",1); PlayerPrefs.SetInt("Button1",0); PlayerPrefs.Save (); } }

Viewing all articles
Browse latest Browse all 1333

Trending Articles