2
I’m developing a game for android but I’m having a hard time saving the type of input. For example in this game the user can choose whether to play on touch or accelerometer, in Unity + remote works well this exchange but when I compile and install the apk on mobile does not work. Can someone help me?
void Start()
{
if (PlayerPrefs.HasKey("playerChoice"))
{
if (value == 1)
{
inputAC.SetActive(true);
inputTC.SetActive(false);
}
if (value == 0)
{
inputAC.SetActive(false);
inputTC.SetActive(true);
}
}
}
void Update()
{
if (gameRunning)
uiManagerScript.ShowScoreText(playerScript.score);
}
public void GameOver(int score)
{
scoreManger.AddScore(score);
gameRunning = false;
playerScript.gameObject.SetActive(false);
uiManagerScript.GameEnd();
plataformSpawnerScript.enabled = false;
playerScript.isDead = true;
plataform.gameObject.SetActive(false);
}
public void StartGame()
{
plataformSpawnerScript.enabled = true;
cameraScript.ResetCam();
uiManagerScript.GameStart();
playerScript.score = 0;
playerScript.isDead = false;
gameRunning = true;
plataform.gameObject.SetActive(true);
}
public void InputChoiceFalse()
{
if (PlayerPrefs.HasKey("playerChoice"))
{
PlayerPrefs.SetInt("playerChoice", playerChoice ? 0:1);
value = 1;
PlayerPrefs.Save();
}
}
public void InputChoiceTrue()
{
if (PlayerPrefs.HasKey("playerChoice"))
{
PlayerPrefs.SetInt("playerChoice", playerChoice ? 0 : 1);
value = 0;
PlayerPrefs.Save();
}
}
public void QuitGame()
{
Application.Quit();
}
}