Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Simple IAP and Soomla help

Discussion in 'Scripting' started by clandis82, Jun 15, 2015.

  1. clandis82

    clandis82

    Joined:
    May 29, 2015
    Posts:
    13
    Hello all,

    I am working on an FPS project and I need to imement in app purchases to it. I am giving the first two levels free. But in order to play additional levels, I want the user to purchase them for 99 cents. I have purchased soomla and simple IAP system for soomla. But none of their documentation shows anything about having a button that loads a level being unlocked after purchasing it through soomla. Can someone please help me to understand how to enable a unity gui 4.6 button after the user has purchased the level. I am a comets beginner at code so I'm clueless as to what to do. Any help would be much appreciated. Thanks in advance.
     
  2. y_nizan

    y_nizan

    Joined:
    Sep 22, 2012
    Posts:
    11
    Hi,

    I suggest you post this also on answers.soom.la - you will get a much quicker response there.

    Yaniv
     
  3. Marceta

    Marceta

    Joined:
    Aug 5, 2013
    Posts:
    177
    You can check balance of purchased item, so if balance of level3_example[Lifetime Virtual Good]
    is larger than 0 user can load that level.

    Code:
    Code (CSharp):
    1. if(StoreInventory.GetItemBalance("level3_example") > 0)
    2. {
    3. //User Purchased/Unlocked this level
    4. }
    Docs:
    http://know.soom.la/unity/store/store_model/#LifetimeVG
     
  4. clandis82

    clandis82

    Joined:
    May 29, 2015
    Posts:
    13

    Would this be all I need to add to the button for it to know when to enable and when not to or is there something more that I would need to add to the code for the button to automatically enable after purchase
     
  5. alexstefan95

    alexstefan95

    Joined:
    Apr 19, 2014
    Posts:
    5
    You need to get a reference to your button. Then you can do something like:
    Code (CSharp):
    1. if(StoreInventory.GetItemBalance("level3_example") > 0)
    2. {
    3.   buttonReference.isActive=true;
    4. }