When I launch my game in game editor or on the phone - it glitches for the 2-3 seconds and calls the function OnApplicationPause. But when I close application/pause in editor it doesn't calls. That's bad for my project so how to fix it? There's function code :
void OnApplicationPause()
{
DateTime time = DateTime.Now;
SaveVariablesInClass();
PlayerPrefs.SetString("SV", JsonUtility.ToJson(save)); //saves special class
}
void SaveVariablesInClass()
{
save.Bananas = bananas;
save.GoldBananas = goldBananas;
save.TwoBananasSpawnChance = twoBananasSpawnChance;
save.HigherBananaLevelChance = higherBananaLevelChance;
save.SimpleBananaStormChance = simpleBananaStormChance;
save.GoldBananaChance = goldBananaChance;
save.TwoGoldBananaChance = twoGoldBananaChance;
save.offlineEfficiency = offlineEfficiency;
save.offlineProductionTime = offlineProductionTime;
save.goldCoefficient = goldCoefficient;
save.BonusLevels = bonusLevels;
save.GoldBonusLevels = goldBonusLevels;
save.SimpleBonusLevelPrices = simpleBonusLevelPrices;
save.GoldBonusLevelPrices = goldBonusLevelPrices;
save.simpleMaxLevels = simpleMaxLevels;
save.goldMaxLevels = goldMaxLevels;
save.time = time.ToString();
save.CurrentSimpleBonus1 = currentSimpleBonus1;
save.LaunchedGame = launchedGame;
}
c#orjavascriptbut probably not both. What do you mean byit slows down a bit? When you are launching the App how can it slow down? Also have a look atOnApplicationPauseOnApplicationPauseaboolparameter and skip if it isfalse?true. What isSaveVariablesInClass();doing? just trying to see where the lag could be caused