W
W
WasTabon2020-09-18 21:57:19
Unity
WasTabon, 2020-09-18 21:57:19

Why doesn't the OnApplicationQuit() method work?

void Awake()
    {
       sympathy  = PlayerPrefs.GetInt("sympathy", 0);
       allSympathies = PlayerPrefs.GetInt("allSympathies", 0);
       sympathyBonus = PlayerPrefs.GetInt("sympathyBonus", 1);
    }

private void OnApplicationQuit()
    {
        PlayerPrefs.SetInt("sympathy", sympathy);
        PlayerPrefs.SetInt("allSympathies", allSympathies);
        PlayerPrefs.SetInt("sympathyBonus", sympathyBonus);
    }


After the reboot, it's still default values, what could be the problem? Despite the fact that it works in Unity, but not in the APK file

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2020-09-18
@WasTabon

Because on an android with an exit as such, there is a big zh..a - there is no exit as such, there is folding and kill. Use methods for folding - OnApplicationFocus for example.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question