Unity Codeless IAP 2021 (Android and iOS) - Easy Unity Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hey what's up, welcome to Hooson In this video You will be learning how to make Codeless in-app purchases in Unity After we're done I'll walk you through the process Of connecting it with the app store connect And google play store Alright let's begin The first thing we need to do is to configure our game project Head over to the "File" tab at the top-left hand corner of Unity And click on "Build Settings" Make sure you're set to either iOS or android platform Once you've configured your game project It's time to enable the Unity IAP service Head over to the "Window" tab at the top of Unity "General" and then "Services" In the services window You can see that in-app purchasing is currently turned off right now So let's click on it And we need to create a project ID for our game If you've already created one You can link this project to that project ID as well I don't have project ID So I'm going to create a new one Let's select an organisation first And then click on create project ID Now they'll ask you Will your app be primarily targeted to children under age 13 I'll choose "No" for this tutorial But if your game is targeted towards children Choose the "Yes" option Click "Save" And as you can see The in-app purchasing settings hasn't been turned on yet So click on it to enable Unity IAP service Once it finishes loading You can see that it has been turned on And now we need to install the purchasing package into our game project In the purchasing package section Click on install latest version Once it finishes loading We now need to import the Unity IAP package into our project In the welcome section Click on "Import" Once you've finished importing the package A new folder "Plugins" Will be automatically added to your project This folder contains the Unity Purchasing asset Which is required to use Unity IAP Now we can begin implementing Unity in-app purchases into our project Firstly, let's create an empty game object called "IAP Manager" Next I'm going to create three IAP buttons Under the "IAP Manager" game object To add an IAP button to your scene Right click on the hierarchy tab And you should see a Unity IAP section And we want to create an IAP button One for consumable product One for non-consumable product And the last button will be restore purchases So a consumable product Is one that a user consumes to receive in-game content A great example of a consumable Are in-game currencies like gems and coins On the other hand A non-consumable product Is a product that is purchased once And provides a permanent benefit A good example of a non-consumable product Would be skins or remove ads Once the player purchase these products It will be permanently associated with the player's account Lastly, the restore purchases button Allows players to transfer in-app purchases To other devices such as new iPhone. The restore button is only required on the app store connect If you're just publishing your game on google play store You can remove this restore purchases button Let's select our consumable button And right now we need to add our product Let's click on the IAP catalog button The IAP catalog window will pop up And this is where we will add our product I'm going to create my consumable product first And I will be using "500 coins" as my consumable product In this tutorial So there is a specific format for naming our product ID It starts with "com." Your company name or individual name This will depend on how you register your developer account With Google and Apple If you register as an individual Use your own name If you register as a company Use your company's name "." the name of the game "." the name of the product So if I register as a company It would be like "com.hoosontechnology" Which is my company name ".iaptutorial" Which is the name of my game ".coin500" which is my product name Another example will be "com.jason" which is my name ".botattack" which is the name of my game ".coin500" which is my product name So if players were to buy this product They will be receiving 500 coins The type of product will be consumable For the title I'm going to just name it "500 coins" For the description You can give a short explanation On what this product is about So in my case It'll be something like Gives the player 500 coins Now let's expand the google configuration And apple configuration section And we want our price to be the same in both google play store And app store connect If you click on the price tier You can see many different options Select a price for your product And make sure you enter the same amount In the google configuration section as well Since I selected "USD 9.99" for the app store I'm going to put "9.99" for the google play store One last important step to take note We need to check the "Automatically Intialize UnityPurchasing" option Alright let's close the IAP catalog window And I'm going to assign the product ID to my consumable IAP button Make sure the button type is set to purchase Alright as you can see in my game project I've created a title text and description text So right now I'm going to assign the title to the title text And description to the description text And lastly the button text to the price text And when I click on the play button The title, description and price Will be automatically added for me This is one of the many benefits of using the codeless IAP Now let's create another product ID For our non-consumable purchase I'm going to select the non-consumable button And open up the IAP catalog window again Let's add a new product This time round, I'm going to name my product ID "com.hoosontechnology" ".iaptutorial.removeads" Remember to change the product type to non-consumable Title will be remove advertisement Description will be All ads will be permanently removed Let's set the price for our remove advertisement product Select a price from the apple configuration section first And then key in the same price On the google configuration section Once you're done Close the IAP catalog window And with the non-consumable IAP button selected I'll change the product ID To the remove advertisement ID Let's assign the title Description and price text as well Lastly, select the restore purchases button And we want to change the button type to restore That's all you need to do for the restore purchases button Now when you click play You should be able to see your consumable product Non-consumable product And restore purchases button implemented in the game Now that we've implemented our IAP button We need to create a new C# script To actually to give the players the product they've bought in your game So let's create a new C# script called "IAPManager" And open it up Go ahead and delete the "Start" and "Update" function As we won't be using it And we want to add the "UnityEngine.Purchasing" namespace Next we need to create two functions For our IAP button Create a public function called "OnPurchaseComplete" with a "Product" parameter And a public function called "OnPurchaseFailed" With a "Product" and "PurchaseFailureReason" parameter Next we need to create two string type variables To store our product ID So my first variable will be called "coin500" And I'm going to copy and paste My "coin500" product ID into it Now I'm going to create another one called "removeAds" And then copy and paste my "removeads" product ID into it Head over to the ""OnPurchaseComplete" function And this is the function we want to call When the players successfully paid for the product We will just use a simple if statement to check which product the players bought So "if(product.definition.id == coin500)" I'm going to reward the player with 500 coins Since this is just a tutorial I'll just "Debug.Log("You've gained 500 coins")" In your actual game This is where you should be rewarding your players "if(product.definition.id) == removeAds" I'll just "Debug.Log("All ads removed!")" In the "OnPurchaseFailed" function We want to show the reason why the product wasn't bought successfully So let's "Debug.Log" "(product.definition.id + " failed because" + failureReason)" Save the script and head back to Unity Attach the "IAP Manager" script To the "IAP Manager" game object And we want to call the "OnPurchaseComplete" function When the purchase is successful And call the "OnPurchaseFailed" function When the purchase isn't successful Let's do the same for the other IAP button as well Once you're done, it's time to click play and give it a try Alright perfect The coin IAP button is working well And as you can see It says here "You've gained 500 coins" Let's try the remove ads IAP button Alright perfect You can see that it says "All ads removed!" You've learned how to implement a consumable IAP button And a non-consumable IAP button I have another additional step for the restore button For those who wants to publish their game on both App store connect and google play store If you're just publishing your game for google play store You can skip to the "Connecting with google play store" part of the video Alright for those who wants to publish on both app store And google play store Let's finish up the last step Before we connect to the specific store itself Open up the "IAPManager" script again And we want to create a new public game object called "restoreButton" Create an "Awake" function and in the "Awake" function We want to check if the player is on an iPhone or android device So if the player is not on an iPhone We want to disable the "restoreButton" game object Because the restore button is only needed for iPhone users Alright save the script and head back to Unity Let's assigno ur restore button And right now I'm going to test on an iPhone And you can see that the restore button is still here Let's change to an android phone and try it out Alright perfect the restore button has been disabled Alright we're done with the IAP implementation So all that's left to do is to connect it With the google play store and app store connect To connect our in-app purchases to google play store Is actually really simple Firstly let's open up our IAP catalog window again And at the bottom You can see an app store export button let's click on it and we want to select google play CSV Save it somewhere in your computer And we want to head over to the google play console Once you're in the google play console Click on your app And we want to head over to the in-app products section One thing to take note You'll only be allowed to create In-app products on google play console Only after you've uploaded your game over here Simply click on the import button And we want to import the file we saved earlier Into the google play console Let's click on import And that's all you've got to do You can see the status is set to active And when I view the in-app product You can see the name Description and price has been automatically added for me Alright one extremely important thing to take note If you take a look at the price of the products You'll notice that it's actually in Singapore currency Which is the country I'm from So if I want it to be in US dollars I actually need to convert the currency myself On google play console For those living in the states You don't have to worry about the pricing But for those living outside of United States It's actually a little bit more troublesome for us As we need to convert our own currency to USD Alright we're done connecting our in-app purchases with google play console So for those who wants to publish on the app store connect as well Let's continue with this tutorial Alright in the app store connect The first thing we need to do is to head over to the agreements Tax and banking section Because in order to have In-app purchases on the app store connect We must agree to the "Free Apps" and "Paid Apps" agreement Once you're done Head over to your app on the app store connect And on the left You'll see an in-app purchases section And we want to click on manage Let's click on the plus icon to add our in-app purchases I'm going to start with my consumable product first And click on create For the reference name We can just put the title of our product Which in my case is "500 coins" Product ID is extremely important We want to copy our product ID in Unity and paste it here Make sure you copy the correct product ID For the pricing just follow the tier you selected in Unity So Apple has their own conversion rate for every country's currency So even though you see it says here SGD 14.98 Which is the Singapore dollars It's actually the same as USD 9.99 Display name will be the title of our product back in Unity And the description will be our description back in Unity as well Head down to the review information section And Apple requires us to provide a screenshot And brief description of our IAP button So let's head back to Unity to screenshot our IAP Button So there is a specific dimension For our screenshot which Apple requires Which is "640 x 920 Pixels" So it's actually really simple If you take a look at your game tab You'll be able to see different options of aspect ratio available So simply add a new aspect ratio For the label we'll just name it "Screenshot" The width will be 640 And the height will be 920 Now we want to maximize our game window And make sure the scale is at 1 Next, simply use a snipping tool on your computer and crop this area out Do make sure your screenshot is exactly "640 x 920 pixels" Else you won't be able to upload it successfully If you're having trouble uploading it on the app store connect It's most probably your screenshot isn't in the correct size So simply use any picture editing software To make your screenshot exactly 640 x 920 pixels Once your screenshot is uploaded Simply give a brief description on the IAP button Example would be It is the first button on our store It'll give the player 500 coins Once everything is done Simply click save And I'm done for my consumable product Alright now let's add another in-app purchases For our non-consumable product The reference name will be "Remove Advertisement" Copy the product ID in Unity and paste it here Make sure you copy the correct product ID For the pricing just follow the tier you selected back in Unity The display name will be the title of our product back in Unity And the description will be our description back in Unity as well Head down to the review information section I'm going to use the same screenshot And the review notes will be something like It is the second button in our store It'll remove all ads Alright we're done in the app store connect The only thing left for you to do is to send this in-app purchases Together with your app for Apple to review it So that's all for this video Do click the like and subscribe button if you enjoyed this video I'll be posting more Unity tutorial and behind the scene of my game dev journey In the future as well Also do check out my first ever mobile game that I published for android and iOS Called "Bot Attack" Link to download "Bot Attack" will be in the description below I'll see you guys in the next video Peace
Info
Channel: Hooson
Views: 59,836
Rating: undefined out of 5
Keywords: Hooson, unity iap 2021, unity codeless iap, unity iap, unity iap tutorial 2021, unity iap codeless, unity in app purchase, unity in app purchases, unity in app purchase tutorial, unity iap tutorial, unity ios in app purchase tutorial, unity android in app purchase tutorial, codeless iap unity, codeless iap, unity codeless iap 2021, unity codeless iap tutorial
Id: tPh6RJ3pS74
Channel Id: undefined
Length: 17min 20sec (1040 seconds)
Published: Tue Apr 20 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.