Search Unity

  1. Engage, network and learn at Unite Austin 2017, Oct 3 - 5. Get your ticket today!
    Dismiss Notice
  2. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  3. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  4. Unity 2017.1 is now released.
    Dismiss Notice
  5. Unity 2017.2 beta is now available for download.
    Dismiss Notice

Unity IAP - need some help

Discussion in 'Unity IAP' started by iALNA, Sep 2, 2017.

  1. iALNA

    iALNA

    Joined:
    Sep 27, 2016
    Posts:
    96
    Hello all, guys. I'm studying Unity and now I'm trying to made some IAP in my game. It will be simple. It will be like some coins add. So, my question is - I added IAP plugin, then, I found simple (as I see) way to made IAP using https://docs.unity3d.com/Manual/UnityIAPCodelessIAP.html - IAP Button. So, I added it, made some products ID. Then in this IAP Button Component there is some fields - "On Purchase Complete" and "On Purchase Failed". So, as I think, if I want to add some "Gems" after purchase I need attach to field "On Purchase Complete" some script that do this? If yes, I made simple test script like this:
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class IAPScript : MonoBehaviour
    4. {
    5.     public void GemsSmall()
    6.     {
    7.         int gems = PlayerPrefs.GetInt("Gems");
    8.         PlayerPrefs.SetInt("Gems", gems + 100);
    9.     }
    10. }
    11.  
    So, after I pushed button, then pushed "Buy" - I got 100 gems. I would like to ask you - is it correct that I done? Please, give me some advices!

    Thx for attention and sorry for my english :)
     
  2. iALNA

    iALNA

    Joined:
    Sep 27, 2016
    Posts:
    96
    Any help? :(
     
  3. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    168
    You'll also want to test that it works correctly when the user reinstalls your game.
     
  4. iALNA

    iALNA

    Joined:
    Sep 27, 2016
    Posts:
    96
    You mean, that after user buy some coins and if he reinstall game, all playerprefs(coins) will deleted?
     
  5. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    168
    iALNA likes this.
  6. iALNA

    iALNA

    Joined:
    Sep 27, 2016
    Posts:
    96
    Thank you, I understand what are you mean. Today I read some information about Google Play plugin that allow save some game progress in some cloud. Is it true? If yes, can I use it to solve problem, that you noticed upwards?
     
  7. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    168
    Try it and see! And don't forget to test.
     
  8. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,330
    Isn't virtual currency usually a consumable so there's no need to restore?
     
  9. iALNA

    iALNA

    Joined:
    Sep 27, 2016
    Posts:
    96
    Yes, I read the same. So, I have been thought about it, do I need to made cloud save? In one side, users who buy some consumables will lose it if they delete game... Is it possible? But, if think, user decide to delete game himself, so this problem is user's. But, if think from moral side, will better to made some cloud save to save it's progress, because it is insulting if you remove the game, and then lose all the progress ... you may need to remove the game to clean the memory or to get rid of any error ... But I'm worried about cloud save, it will be hard for me, because im only learning unity... So, what your's opinion about it?