当我单击按钮1时,我想要3个按钮,隐藏该按钮并显示带有PlayerPrefs的所有按钮,当我单击按钮2时,我隐藏该按钮并显示带有PlayerPrefs的所有按钮,我测试了我的代码,但使用了按钮2唯一
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();
}
答案 0 :(得分:3)
因此,您要隐藏单击的按钮,然后显示其余的按钮吗? 那么只有一个playerpref可以起作用,其中包含隐藏的按钮?
oc get pods