Search Unity

[Closed] Unity IAP / Text Problem

Discussion in 'Unity IAP' started by BrodyDaChappy, Dec 28, 2016.

Thread Status:
Not open for further replies.
  1. BrodyDaChappy

    BrodyDaChappy

    Joined:
    Jan 6, 2016
    Posts:
    10
    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.
    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using UnityEngine.UI;
    4. using System.Collections;
    5. using CompleteProject;
    6.  
    7.   publicclassMenuButton:MonoBehaviour{
    8.   publicButton button;
    9.   publicText text;
    10.   publicOnGUI2D gui;
    11.   publicPurchaser purchaser;
    12.  
    13.   voidStart()
    14. {
    15.    if(DataObject.instance ==null)
    16. {
    17.    DataObject.instance =newDataObject();
    18.    DataObject.instance.Load();
    19. }
    20.    Reset();
    21. }
    22.    publicvoidReset()
    23. {
    24.    if(DataObject.instance.adsRemoved)
    25. {
    26.    button.onClick.RemoveAllListeners();
    27.    button.onClick.AddListener(gui.Endless);
    28.    text.text ="Endless Mode";
    29.    Debug.Log("Text Changed Endless");
    30. }
    31. else
    32. {
    33.    button.onClick.RemoveAllListeners();
    34.    button.onClick.AddListener(purchaser.BuyNonConsumable);
    35.    button.onClick.AddListener(Reset);
    36.    text.text ="Endless\nMode &\nRemove Ads";
    37.    Debug.Log("Remove Ads & Endless Text");
    38.    }
    39.   }
    40. }`
     
Thread Status:
Not open for further replies.