Search Unity

[Solved] IAP: Loading scene in ProcessPurchase and multiple IStoreListeners.

Discussion in 'Unity IAP' started by IntDev, Dec 9, 2015.

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

    IntDev

    Joined:
    Jan 14, 2013
    Posts:
    152
    Loading scene in ProcessPurchase

    In the ProcessPurchase method I enable the purchased item for the player, but I need to load a scene right after. However, as this method needs to return a value I'm afraid of loading a new scene and not to fire that response properly:

    Code (CSharp):
    1. public PurchaseProcessingResult ProcessPurchase (PurchaseEventArgs e)
    2. {
    3.     // item purchased successfuly
    4.     GameData.Player.Premium = true;
    5.  
    6.     // Can I safely do this here?
    7.     SceneManager.LoadScene("scene");
    8.  
    9.     return PurchaseProcessingResult.Complete;
    10. }
    Multiple Listeners

    I'd like to make two scripts as listener of the IStoreListener. One will initialize and listen (UnityPurchasing.Initialize(this, builder)), and the other needs only to listen. Should I use the same initialize method to register a new listener? In this case the problem is that I will not have the "builder" param in the second script and I don't know if it will reinitialize it instead of just register a listener.
     
    Last edited: Dec 9, 2015
  2. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    You should be fine to load a new scene there.

    If you want additional listeners to be triggered you can define your own events and trigger them from your ProcessPurchase method.
     
Thread Status:
Not open for further replies.