Unity IAP Button Text Change
Hi All,
I have created a button on my main menu with the text "Remove Ads & Endless" clicking on this initialises purchase process, upon successful purchase the text then changes to "Endless" meaning all went well and the new game mode is now unlocked to play..
The problem i am having is that once purchase is completed the text does not change until i change scene, for instance into the "Credits" scene" and then back into "Main Menu". I also have the same issue when coming out of the new game mode "Endless" but this reverts the Text back to "Remove Ads & Endless", this then makes the new game mode unavailable even after purchase, then it seems to correct itself and revert back to "Endless" when i quit the game and go back in and everything is ok after that :S. below is the script i use to make the text change.
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using CompleteProject;
public class MenuButton : MonoBehaviour {
public Button button;
public Text text;
public OnGUI2D gui;
public Purchaser purchaser;
void Start ()
{
if (DataObject.instance == null)
{
DataObject.instance = new DataObject();
DataObject.instance.Load();
}
Reset();
}
public void Reset()
{
if (DataObject.instance.adsRemoved)
{
button.onClick.RemoveAllListeners();
button.onClick.AddListener(gui.Endless);
text.text = "Endless Mode";
Debug.Log("Text Changed Endless");
}
else
{
button.onClick.RemoveAllListeners();
button.onClick.AddListener(purchaser.BuyNonConsumable);
button.onClick.AddListener(Reset);
text.text = "Endless\nMode &\nRemove Ads";
Debug.Log("Remove Ads & Endless Text");
}
}
}`
Your answer
Follow this Question
Related Questions
Unity IAP Issues 0 Answers
UI Text created from C# Script 0 Answers
Add object using other scene,Change something in scene from the menu 2 Answers
Cant find text objects after being renamed. 1 Answer
How to assign Text of a Panel child via Script on Panel 0 Answers