Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Unity 2022 Mobile Game Development - Third Edition

You're reading from  Unity 2022 Mobile Game Development - Third Edition

Product type Book
Published in Jun 2023
Publisher Packt
ISBN-13 9781804613726
Pages 480 pages
Edition 3rd Edition
Languages
Author (1):
John P. Doran John P. Doran
Profile icon John P. Doran

Table of Contents (21) Chapters

Preface 1. Part 1: Gameplay/Development Setup
2. Chapter 1: Building Your Game 3. Chapter 2: Project Setup for Android and iOS Development 4. Part 2: Mobile-Specific Features
5. Chapter 3: Mobile Input/Touch Controls 6. Chapter 4: Resolution-Independent UI 7. Chapter 5: Advanced Mobile UI 8. Chapter 6: Implementing In-App Purchases 9. Chapter 7: Advertising Using Unity Ads 10. Chapter 8: Integrating Social Media into Our Project 11. Part 3: Game Feel/Polish
12. Chapter 9: Keeping Players Involved with Notifications 13. Chapter 10: Using Unity Analytics 14. Chapter 11: Remote Config 15. Chapter 12: Improving Game Feel 16. Chapter 13: Building a Release Copy of Our Game 17. Chapter 14: Submitting Games to App Stores 18. Chapter 15: Augmented Reality 19. Index 20. Other Books You May Enjoy

Implementing In-App Purchases

As mentioned in Chapter 7, Advertising Using Unity Ads, there are many options out there when it comes to selling your game on a mobile platform. If you decide to go free-to-play, in addition to showing ads, there is also the ability to sell people additional content and/or advantages through the use of In-App Purchases (IAPs). This can be a way to engage users of your game and convert them from free players into paying customers.

Typically, these can be options such as removing ads or offering themes to players, but you can also do things such as unlock new levels and add additional content so that people addicted to your game will be clamoring to give you more of their time. Alternatively, you can also think of your IAPs as items that players will want to buy in order to enhance their gameplay experiences, such as power-ups and upgrades.

In this chapter, we will integrate Unity’s IAP system into our project and take a look at how to create...

Technical requirements

This book utilizes Unity 2022.1.0b16 and Unity Hub 3.3.1, but the steps should work with minimal changes in future versions of the editor. If you would like to download the exact version used in this book, and there is a new version out, you can visit Unity’s download archive at https://unity3d.com/get-unity/download/archive. You can also find the system requirements for Unity at https://docs.unity3d.com/2022.1/Documentation/Manual/system-requirements.html in the Unity Editor system requirements section.

You can find the code files for this chapter on GitHub at https://github.com/PacktPublishing/Unity-2022-Mobile-Game-Development-3rd-Edition/tree/main/Chapter06%20and%2007.

Setting up Unity IAP

Unity IAP is a service that allows us to sell a variety of different items to players within our game projects and is currently supported by the iOS App Store, Mac App Store, Google Play, Windows Store, Amazon Appstore, and more, by default. So, using this, we can easily sell our items in many different places. We have already set up Unity Services in Chapter 7, Advertising Using Unity Ads, so this will be a lot easier to get going. Perform the following steps to add Unity IAP:

  1. Open the Services window by going to Window | Package Manager, and then click on the Services button on the top toolbar.
  2. From there, scroll down to the In App Purchasing item and then click on the Install button.
Figure 6.1: The In App Purchasing option from Package Manager

Figure 6.1: The In App Purchasing option from Package Manager

  1. A window will pop up asking for you to confirm that you would like to activate the Purchasing service package. Click on the Ok button.
Figure 6.2: Activating the Purchasing service
...

Adding a button to restore purchases

On platforms that support it (Google Play and Universal Windows Applications, most notably), if you purchase something, uninstall, and then reinstall a game using Unity IAP, it automatically restores any products the user owned during the first initialization following reinstallation.

For those on iOS, users must have the ability to restore their purchases via a button due to Apple requiring them to reauthenticate their password beforehand. Not doing so will prevent our game from being accepted on the iOS App Store, so it’s a good idea to include this functionality if we wish to deploy it there. Let’s look at the steps to do just that:

  1. Go to the Hierarchy window and select the Remove Ads Button object. Once selected, duplicate it by pressing Ctrl + D.
  2. Change the duplicate’s name by selecting it and changing its name to Restore Button in the Inspector window.
  3. From the Hierarchy window, open up the Text object...

Summary

In this chapter, we covered how to create IAPs by making use of Unity in your project. We first covered how to set up Unity’s IAP system and then dived into using Codeless IAP to easily add a purchasable item to your game. We then created the functionality to restore our purchase if we uninstall and reinstall our game and went over where we can go to set up our purchases depending on the store we want to target. These new skills give you the ability to make additional revenue from your game while also allowing you to target multiple stores and platforms, making it possible for even more people to see it.

Now, of course, having all these ways to make money isn’t going to help us if no one plays our game. In the next chapter, we will get social, learning how we can make use of social media to share our score and get other players interested in our title.

Further reading

For more tips and tricks on improving your freemium strategy, I suggest that you check...

lock icon The rest of the chapter is locked
You have been reading a chapter from
Unity 2022 Mobile Game Development - Third Edition
Published in: Jun 2023 Publisher: Packt ISBN-13: 9781804613726
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 €14.99/month. Cancel anytime}