Search Unity

Unity IAP - need some help

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

  1. Deleted User

    Deleted User

    Guest

    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. Deleted User

    Deleted User

    Guest

    Any help? :(
     
  3. JeffDUnity3D

    JeffDUnity3D

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

    Deleted User

    Guest

    You mean, that after user buy some coins and if he reinstall game, all playerprefs(coins) will deleted?
     
  5. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Deleted User likes this.
  6. Deleted User

    Deleted User

    Guest

    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

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

    andymads

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

    Deleted User

    Guest

    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?