Quantcast
Channel: Questions in topic: "iap"
Viewing all articles
Browse latest Browse all 595

IAP button fails to update GUI after scene change

$
0
0
Hi there, I am having an issue with making purchases to the Google Play Store (fake store) on the scene in Unity. When I load the scene on Play, the IAP buttons are active and show a debug log of purchase complete and adding coins to my coins counter. When the button is pushed and purchased, my coins counter updates with the amount purchased. ---------- When, I change scenes to the game from the menu scene and go back to the menu scene, the IAP buttons no longer update my coins counter when purchased. The debug log still says that the purchase was complete and coins were added. ---------- using UnityEngine; using System; using System.Collections; public class CoinManager : MonoBehaviour { public static CoinManager Instance; public int Coins { get; private set; } public static event Action CoinsUpdated = delegate {}; [SerializeField] int INITIAL_COINS = 100; const string COINS = "COINS"; // key name to store high score in PlayerPrefs void Awake() { if (Instance) { DestroyImmediate(gameObject); } else { Instance = this; DontDestroyOnLoad(gameObject); } } void Start() { Reset(); } public void Reset() { // Initialize coins Coins = PlayerPrefs.GetInt(COINS, INITIAL_COINS); Debug.Log ("Reset Coins To 100 Count"); } public void AddCoins(int amount) { Coins += amount; // Store new coin value PlayerPrefs.SetInt(COINS, Coins); // Fire event CoinsUpdated(Coins); Debug.Log("Coins Have Been Added"); } public void RemoveCoins(int amount) { Coins -= amount; // Store new coin value PlayerPrefs.SetInt(COINS, Coins); // Fire event CoinsUpdated(Coins); } } ---------- On the button, I have the call function "AddCoins" to update the coins counter after a purchase is completed. I have included a few images to view ![alt text][1] ![alt text][2] Any thoughts would be helpful. Thanks [1]: /storage/temp/126026-coins-added-1.jpg [2]: /storage/temp/126027-coins-added-2.jpg

Viewing all articles
Browse latest Browse all 595

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>