- Home /
Question by
Sniper1RDR · Feb 01, 2019 at 12:29 PM ·
buttonsaveinteractable
Interactable not save PlayPrefs
Hi My script is not save If to restart a game, the button "Continue Game" will be inactive Please help me
public class ContinueGame : MonoBehaviour {
public Button startButton;
bool intToBool(int val)
{
if (val != 0)
return true;
else
return false;
}
public void HiddenButton()
{
startButton.interactable = intToBool(PlayerPrefs.GetInt("StartButtons", 1));
PlayerPrefs.Save();
}
}
Comment
Answer by Magso · Feb 01, 2019 at 03:16 PM
void Start()
{
if(PlayerPrefs.GetInt("StartButtons", 0) != 0)
{
return true;
}
else
{
return false;
}
}
would be an easier way of doing it.
Are you sure? You're returning true/false on a void function. And that do nothing.
Sorry, I skipped the fact that it's returning a boolean, I'm assumed there were more lines in there like
intToBool = true;
GetComponent<Text>().color = Color.white;
I copied exactly for less confusion and ended up not making sense... oops