I am very much a beginner but I have pieced together this script which works great to remove the “Rate this game” button… But I would like it to remove it permanently once pressed so I think I need to make use of player prefs if I am not mistaken?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RateGame : MonoBehaviour
{
public GameObject RateButton;
public void OpenURL()
{
Application.OpenURL("http://google.com/");
Debug.Log("is this working?");
RateButton.SetActive(false);
}
}
But I don’t really understand how to do that… I have used player prefs for an integer before but this is different.
Can anyone point me in the right direction please?
Thanks! I think I am getting closer… But may be hideously off ha! And I can’t work out how to implement HasKey. This is what I have now:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RateGame : MonoBehaviour
{
public GameObject RateButton;
public int ButtonPressed;
void Awake()
{
RateButton.SetActive(true);
PlayerPrefs.GetInt("ButtonPressed");
}
public void OpenURL()
{
Application.OpenURL("http://play.google.com/");
Debug.Log("is this working?");
PlayerPrefs.SetInt("ButtonPressed", 1);
RateButton.SetActive(false);
PlayerPrefs.Save();
}
}
In case anyone comes here in future, this does the job:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RateGame : MonoBehaviour
{
public GameObject RateButton;
public int ButtonPressed;
void Awake()
{
RateButton.SetActive(true);
PlayerPrefs.GetInt("ButtonPressed");
if (PlayerPrefs.GetInt("ButtonPressed") == 1)
{
RateButton.SetActive(false);
}
}
public void OpenURL()
{
Application.OpenURL("http://play.google.com/");
Debug.Log("is this working?");
PlayerPrefs.SetInt("ButtonPressed", 1);
RateButton.SetActive(false);
PlayerPrefs.Save();
}
}