Answer the question
In order to leave comments, you need to log in
What to do if PlayerPrefs are reset on the phone?
Data is created, saved and taken from me like this
public int AdsOff = 0;
/* --- вначале задаются --- */
if(!PlayerPrefs.HasKey("AdsOff")){
PlayerPrefs.SetInt("AdsOff", AdsOff);
PlayerPrefs.Save();
}else AdsOff = PlayerPrefs.GetInt("AdsOff");
/* --- так при покупке они сохраняются ---*/
public void ProcessPurchase(string TypePurchase){
switch(TypePurchase){
case "EnAdsOff": PlayerPrefs.SetInt("AdsOff", 1); PlayerPrefs.Save(); break;
.............................
}
}
Answer the question
In order to leave comments, you need to log in
I do not advise using ONLY PlayerPrefs as a way to save a purchase.
If the player buys with real money in the store, then UnityIAP has a great property of the Product (product) class - . hasReceipt
which works with Subscription and Non Costumable products.
In my code, it is implemented like this: when buying, I save it in PlayerPrefs, and I check it like this: if there is an Internet connection, I request the receipt using . hasReceipt
, otherwise I look in PlayerPrefs.
PlayerPrefs can be cleared by the user, also when updating or deleting the application, and the player paid for the purchase - here you have a dissatisfied buyer and a bad review
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question