Advertisement
Guest User

Untitled

a guest
Jul 4th, 2013
986
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.04 KB | None | 0 0
  1. ~ ~ Getting OUYA IAP to work in Unity ~ ~
  2.  
  3. --- SDK ---
  4. first off, you need to be familiar with the OuyaSDK package, all that stuff is available here:
  5. https://devs.ouya.tv/developers/docs/unity
  6.  
  7. and specifically here:
  8. http://www.youtube.com/watch?v=plqEuuilv6k
  9.  
  10. don't forget to follow the ODK setup instructions first (I know, they are sucky but I can't explain them better) here:
  11. https://devs.ouya.tv/developers/docs/setup
  12.  
  13.  
  14. --- PREP ---
  15. You will need to create your game (you don't need to submit it yet):
  16. https://devs.ouya.tv/developers/games
  17.  
  18. then on that same page, download the signing key (key.der) for the game and put it in:
  19. Assets/Plugins/Android/res/raw/key.der
  20.  
  21. you will then need to make a product (or more) for your game's IAP:
  22. https://devs.ouya.tv/developers/products
  23.  
  24. (the identifier is the string you will use to reference the product in your code, the name is what the player will see when purchasing the game)
  25.  
  26. --- SET UP ---
  27. On your 'OuyaGameObject' component (remember, only ever have one in the game at a time!) enter your UUID in the DEVELOPER_ID string. you can find your UUID here:
  28. https://devs.ouya.tv/developers
  29.  
  30. in the same component's Purchasables list, enter your product identifiers that you just set up for the game.
  31.  
  32.  
  33. --- LISTENERS ---
  34. you need a script to listen for IAP and related events, you can find this list of stuff on this page (scroll down past the videos, or ctrl+f "Scene Products Example")
  35. https://devs.ouya.tv/developers/docs/unity
  36.  
  37. the docs don't tell you, but you need to make sure your script has the following line (without quotes) at the top of it to compile:
  38. "using System.Collections.Generic;"
  39.  
  40. a quick overview of the important stuff:
  41. OuyaGetProductsOnSuccess() gives you a list of info about the products you ask for, if you are displaying a price in your game you should always pull it from this list, so you can change the price later and it doesn't break the game.
  42.  
  43. OuyaPurchaseOnSuccess() is fired when the user makes a successful purchase, you should unlock the game right away when this fires.
  44.  
  45. OuyaGetReceiptsOnSuccess() this passes a list of everything the user has purchased, when and for how much. you MUST use this to check if the player has purchased a product before offering to sell it to them again. ideally you should check this at the very start of your game. it's of course a requirement so people who have deleted the game and re-installed will have the game unlock immediately too.
  46.  
  47. --- THE PROCESS ---
  48. first off, you *cannot* do any IAP activities in Start() or Awake() or the like, you must check if OuyaSDK.isIAPInitComplete() returns true first, and only THEN do your IAP stuff.
  49.  
  50. to request the user's UUID, call:
  51. OuyaSDK.fetchGamerUUID()
  52.  
  53. to request the list of available products, use:
  54. List<OuyaSDK.Purchasable> productIdentifierList = new List<OuyaSDK.Purchasable>();
  55. foreach (string productId in OuyaGameObject.Singleton.Purchasables){
  56. productIdentifierList.Add(new OuyaSDK.Purchasable(productId));
  57. }
  58. OuyaSDK.requestProductList(productIdentifierList);
  59.  
  60. to request the list of receipts, use:
  61. OuyaSDK.requestReceiptList();
  62.  
  63. --- TIPS ---
  64. 1) avoid ever showing the option to buy stuff the user has already bought, it's messy and confusing
  65. 2) you can check the receipt list on your game's startup every time if you like, but I like to store a playerprefs var to say if the game has been unlocked or not, this way the user can play offline.
  66. 3) sometimes the OUYA servers go down, there is no such thing as 100% uptime so don't wait forever for those listeners. if something is taking ages, give the player an option to skip all your IAP stuff and just play the free game
  67. 4) testing your IAP doesn't cost you any money, and you can remove test purchases from your dev account here:
  68. https://devs.ouya.tv/developers/purchases
  69. 5) Don't be an asshole. treat your players with respect and not like a pet you can train to give you money. the emphasis with OUYA is "Free-to-Try" and not "Free-to-Play". Do what you like of course, just check your conscience before you commit ;)
  70.  
  71. - @S0phieH
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement