Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Ouya Unity Game Development

You're reading from  Ouya Unity Game Development

Product type Book
Published in Oct 2013
Publisher Packt
ISBN-13 9781783559701
Pages 118 pages
Edition 1st Edition
Languages
Author (1):
Gary Riches Gary Riches
Profile icon Gary Riches

Removing In-App Purchases


The Ouya SDK makes In-App Purchase relatively simple; it integrates nicely with Unity out of the box. Android, on the other hand, can be a pain to integrate with In-App Purchase inside Unity unless you use a plugin from the Asset Store. For this reason, we'll be modifying our Android game to not use In-App Purchase and instead make it work like a full game purchased from one of the many Android app stores.

As we already have the code for giving the player all the levels when we have purchased the game on the Ouya, the simplest way to remove the In-App Purchase requirement would be to set the purchased int in PlayerPrefs when the game starts.

Double-click on your Sokoban script, as we're going to modify our Awake method. Add the following code to the top of it:

#if UNITY_ANDROID
if (OuyaSDK.IsOUYA () == false){
  PlayerPrefs.SetInt("purchased", 1);
}
#endif

The preceding code is checking if we are on Android but not on Ouya, and if that condition is met then we set...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}