How To Use PlayerPrefs To Unlock A Scene After Purchase

Hello,

I’m very new to unity. I purchased an asset called iOS Storkit In App Purchase Plugin. I am trying to get the two buttons to unlock two buttons called Album2 and Album3 after purchase. These buttons are different scenes.

This was in the documentation for the plugin:

Purchase InApp:

KTInApp.SharedController().Purchase(“com.kashiftasneem.thedarkshadow.rem oveads”);

What I have so far:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public static bool GameStarted=false;
public Button Album2;
public Button Album3;
public Button lockedAlbum2;
public Button lockedAlbum3;

private bool Album2Purchased;
private bool Album3Purchased;

//private int Album3Unlocked = 1;
private int Album2Locked = 0;
private int Album2Unlocked = 1;
private int Album3Locked = 0;
// Use this for initialization
void Start () {

PlayerPrefs.GetInt (“Album2Unlock”);
if (Album2Locked == 1) {
lockedAlbum2.image.enabled = false;
lockedAlbum2.enabled = false;
Album2.enabled = true;
}
}
// Update is called once per frame
void Update () {
if (Album2Purchased == false) {

lockedAlbum2.enabled = true;
PlayerPrefs.SetInt (“Album2Unlock”, Album2Locked);
}
if (Album2Purchased == true) {

lockedAlbum2.image.enabled = false;
lockedAlbum2.enabled = false;
Album2.enabled = true;

}
/else {
PlayerPrefs.SetInt (“Album2Unlock”, Album2Locked);
}
/
}

You would not want to put that code in Update (which can trigger more than 50 times per second). You correctly put it in Start(), like you have, but then only in the purchase succeeded callback and set PlayerPrefs there and update the UI if needed. For that asset, you should look at their demo StoreKitTestScene.unity