Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - Baroni

Pages: [1] 2
Simple IAP System / Guide: Steam Store
« on: December 02, 2017, 11:05:39 am »
This guide explains how to configure Steam payments for use in Simple IAP System, viable on Standalone platforms running the Steam Client (Windows or Mac).

Table of Contents:
  • Prerequisites
  • Connecting Steam with PlayFab
  • Importing Steam SDK in Unity
  • Testing payments

1.   Prerequisites

Using Steam payments requires having a Steamworks developer account, where you are able to publish your game to the Steam ecosystem. The creation of a Steam/developer account is not something described here, so it is assumed that you already have a verified and registered Steam account.

Just know that to publish your game in Steam, you will need to pay $100 for creating a unique AppID that acts as an identifier for your game. This AppID is very important for setting up payments in Simple IAP System as well. Note that the application you create in Steamworks needs to be of type "Game" (not "Application", "Video", etc.), otherwise the in-game overlay popup for authorizing payments will not show up!

Additionally, since Steam payments are passed through the player's account on PlayFab, it is required that you've gone through our PlayFab integration guide (Full Suite) as well and understand all limitations implied by this dependency. Namely, your app needs an active internet connection at all times, in addition to providing a login system for restoring user purchases between sessions - if you are using our sample "UserLogin" scene, the latter is already handled, since it automatically signs you into PlayFab using your active Steam account.

2.   Connecting Steam with PlayFab

Steam payments are a separate extension on your title's PlayFab page, which you can find in the Add-ons > Monetization tab. Click on the Steam Add-on and enter the required details to enable it within PlayFab.

  • Enter the AppID that has been assigned for your application in Steamworks
  • Enter the Steamworks developer API Key that can be created on this page
  • Enable "Use Steam Payments sandbox endpoint for test transactions"

3.   Importing Steam SDK in Unity

In order to access the Steam payments API, you have to import the Steam SDK into your Unity project. There are various wrappers out there, but I've found the Steamworks.NET package to be a reliable solution. Head over to its installation page and download & import its latest unitypackage file (from the releases page on GitHub).

After importing the package into your Unity project, please follow along with the other "Unity Instructions" that are written on the installation page above, specifically entering your own AppID and restarting Unity.

Next, add the SteamManager script to a new empty game object in your first login scene. If you do not have your own PlayFab login scene, you can use our "UserLogin" sample scene and do it there. This script is responsible for establishing a connection between your game binaries and the Steam network on launch.

The SteamManager script has a nice "DRM" function built in. It checks whether the Steam client is running, and will start it if it's not - via SteamAPI.RestartAppIfNecessary (more on this page). To make it work properly, open the SteamManager script, scroll down to the SteamAPI.RestartAppIfNecessary call and replace "480" with your own AppID.
This is optional: while you're at it, you could add an #IF PLAYFAB_STEAM define at the very top of the script (and an #endif at the last line), so that it only compiles for the standalone platform, when Steam has been chosen in Simple IAP System's Plugin Setup window.

Lastly, open Simple IAP System's PluginSetup window (Window > Simple IAP System > Plugin Setup) and make sure that Standalone = Playfab Steam and PlayFab Service = Full Suite is selected.

4.   Testing payments

Testing Steam payments requires the Steam overlay to show up (where you are able to authorize in-app purchase transactions). The Steam overlay visibility can be a bit inconsistent at times, especially if you are launching your game right within Unity. Because of that, it is recommended to just "Build" - not "Build & Run" your game with Unity. After you created the build, log into the Steam Client with your Steamworks developer account. Press ADD A GAME > Add a Non-Steam Game and link the executable you just built with Unity. Then, run it from within Steam - the Steam overlay should show up at launch, as expected. If you are making a new test build, make sure to replace the existing executable (so that you don't have to re-link it) and launch it from Steam as before.

Simple IAP System / Guide: PayPal
« on: July 15, 2017, 11:19:05 pm »
This guide explains how to configure PayPal payments for use in Simple IAP System, viable on WebGL and Standalone platforms - note that platforms having an own store do not allow PayPal payments for buying virtual goods as they want you to use their native billing system (e.g. Google Play or iTunes, so they can take their 30% cut). However, using PayPal on these platforms is allowed for selling physical goods too, such as t-shirts, stuffed animals and other merchandise, which the native stores do not support selling.

Table of Contents:
  • Prerequisites
  • Connecting PayPal with PlayFab
  • Adding PayPal account permissions
  • Shop setup in Unity
  • Testing PayPal payments

1.   Prerequisites

Needless to say, using PayPal payments requires having a PayPal account. The creation of a PayPal account is not something described here, so it is assumed that you already have a verified and registered PayPal account. It is recommended to use a PayPal business account, as that allows you to specify your company name on payments. If you have an existing personal account, you can also upgrade it to a business account in your profile settings.

Additionally, since PayPal payments are passed through the player's account on PlayFab, it is required that you've gone through our PlayFab integration guide (Full Suite) as well and understand all limitations implied by this dependency. Namely, your app needs an active internet connection at all times, in addition to providing a login system for restoring user purchases between sessions. This limitation could be lifted if you are only using PayPal for selling physical goods and do not need to maintain a consistent user inventory for these type of in-app purchases.

2.   Connecting PayPal with PlayFab

PayPal payments are a separate extension on your title's PlayFab page, which you can find in the Add-ons > Monetization tab. Click on the PayPal Add-on and enter the required details to enable it within PlayFab.

You can find your "PayPal Merchant ID" in your PayPal account, under Profile > Account settings > Merchant account ID, or just enter the email address you've registered with on PayPal. The "PayPal Return Link" is the page where users get redirected to after a complete or cancelled purchase. The order ID and token get attached to the url, so you could retrieve it for a custom action on your own server, for example. Otherwise, a simple public url would do, e.g. your game's support website, as the final transaction confirmation will happen in-game (more on this later).

3.   Adding PayPal account permissions

In the last chapter you've told PlayFab your PayPal credentials. But at this point, PlayFab still does not have the permission to execute anything on PayPal on your behalf. So in order to grant them access for handling your checkouts, you have to navigate to the following menu while logged in with your PayPal account: Tools > All Tools > API Access > Grant API permission, or click on this direct link for the third party permission page.

As the "Third Party Permission Username", enter and press on "Lookup" to proceed to the permission administration page. The only permission you need to grant access to is the very first permission listed on the screenshot below - the permission for letting PlayFab do express checkouts for you. Check it and click on the "Add" button.

4.   Shop setup in Unity

You are probably familiar with how the default shop scene in Simple IAP System is built: the IAPManager prefab usually gets carried over from a different (the first) scene, but the shop scene contains the ShopManager prefab, and in its component inspector, references to a UI window for displaying success/error messages whenever users purchase a product.

Now with the PayPal integration, you might have noticed that there is an additional UI window, a confirmation window, in the scene that is also referenced on the ShopManager prefab.

This confirmation window is necessary for completing any open PayPal transaction in-game. As the PayPal payment does not happen in-game, but in the user's browser (for security reasons), your app cannot know when the transaction has gone through successfully. Because of that, the transaction needs to be refreshed in-game after payment, so that it can be completed by PlayFab. In turn, the user is granted the appropriate product he purchased. This also means that without refreshing the transaction in-game, no reward will be given as the payment has not been authorized on PayPal's side (and no funds will be deducted on the user's PayPal account).

The confirmation window is being shown automatically at the time a PayPal payment gets initiated. It has two hidden buttons though, which are not shown right at the beginning: the actual refresh and close button. These buttons will only show up after a certain amount of time has passed (20 seconds by default). This is to ensure that the user cannot refresh the transaction right away (which would return a failed transaction state), but has actually to pay for the product in the browser first. If the refresh button is pressed in-game while the PayPal payment is not finished yet, the refresh button gets hidden for another 10 seconds, whereafter the user can retry again. A successful refresh disables the confirmation window.

5.   Testing PayPal payments

Unfortunately, PlayFab does not support PayPal's sandbox environment. In order to test PayPal payments, you have to use a real PayPal account and pay real money. I would recommend setting up a product for $0.01 in Simple IAP System / PlayFab, so you are not losing that much money for testing per transaction. You also have to use two separate PayPal accounts for testing, as your PayPal (business) account cannot buy products from itself.

Simple IAP System / Guide: PlayFab integration
« on: July 07, 2017, 08:57:22 pm »
PlayFab integration is in active development. Please see chapter 1 below for current limitations and restrictions that apply.

This guide explains how to configure PlayFab services for Simple IAP System, specifically cloud save and receipt validation. Additionally, methods are being explained for keeping local user inventory in sync with PlayFab.

Table of Contents:
  • Prerequisites
  • Creating a PlayFab account
  • Creating your store catalog
  • Importing the PlayFab Unity SDK
  • Using receipt validation only
  • Logging in the user in Unity
  • Feature Overview
  • In-game Synchronization
  • Adding Cloud Scripts

1.   Prerequisites

What else can you do to avoid cheating? To put it simple – don’t do everything on the client, but verify each user action on external servers. The PlayFab 'full' integration in Simple IAP System (not only receipt verification) is a great starting point for that by keeping everything in sync with cloud save and doing critical transactions (like purchasing) on their servers only.

To not postpone big updates several months, we've decided to implement PlayFab in 3 phases in Simple IAP System:
  • 1. phase: cloud save requires an online connection at all times. No data is saved on the device.
  • 2. phase: save data on the device too. Handle data conflicts caused by different server or local data version in a popup presented to the user.
  • 3. phase: hybrid - make it possible to go from online > offline or offline > online during the game. Compare local/server data and handle data conflicts automatically based on developer defined merging rules.
The first phase is what landed in the initial 4.0 version of Simple IAP System. As it requires an online connection throughout the whole play session, it is the most secure solution by far, altough better suited at devices supporting a reliable internet connection (desktop pc's via ethernet or mobile devices using wi-fi). Please keep that in mind when making use of this first iteration. Basically you have two options with online-only games when there is no internet connection available:
  • logging into PlayFab is not possible - it would be best to disallow entering the game at this state
  • or, only permit offline mode without earning & spending (such as a training mode with local scores)

Also note that with the various different native plugins supporting mobile login via PlayFab (i.e. Play Game Services by Google), each of them would need a separate integration guide in Unity. That's something that is already being worked on, but that's why they're not quite ready yet for the first release. Unless you're implementing this yourself, the default login method is via registered email addresses for now (except for Facebook, more on this in chapter 6), which is the most common technique for desktop applications.

With that out of the way, let's continue by creating your PlayFab developer account.

2.   Creating a PlayFab account   

Creating a PlayFab developer account is easy and free. Sign up here:

Once you're logged in, you will be greeted by a somewhat empty screen, where you can define your company and game name. In PlayFab, when speaking about games, they are usually referred to as 'titles'. Each game must have its own title (or dashboard), which is used to independently track users, purchases, cloud scripts and all the other stuff PlayFab provides.

If you've created your first title, it should be shown under your games page along with its generated title identifier.

3.   Creating your store catalog

Now with the title created in PlayFab, we need a way to transfer all the different in-app purchase products from Unity to PlayFab. Fortunately, this is very easy by using the JSON export provided in Simple IAP System, as it already contains the correct format and properties. Open the IAP Settings editor under Window > Simple IAP System > IAP Settings. Clicking on the 'Export to JSON' button and choosing an export folder will result in the following files being created:

  • SimpleIAPSystem_Currencies.json (currencies with name and default value)
  • SimpleIAPSystem_IAPSettings.json (all IAP products, including free ones)
  • SimpleIAPSystem_IAPSettings_PlayFab.json (all IAP products, excluding free ones)
You will make use of the files highlighted in bold. As it's unnecessary to save or auto-grant free products in PlayFab, they are not tracked on their servers at all, but only exist in your game.

In order to import your products in PlayFab, head over to your title's Economy > Currencies section. Click the 'Upload JSON' button and select the previously created SimpleIAPSystem_Currencies.json file. We have to import currencies first, since other products cannot be created when using a non-existent currency.

After that, go to the Economy > Catalogs section and upload all of your IAP products as well, by clicking on 'Upload JSON' and selecting the SimpleIAPSystem_IAPSettings_PlayFab.json file. You can then click on your catalog ID and verify that all products and currency bundles are actually there.

Make this catalog your primary catalog by clicking on the small settings icon and toggling the 'Primary Catalog' checkbox. You can see that everything is correct when the catalog is showing 'Primary' in its header.

4.   Importing the PlayFab Unity SDK

First of all, download the PlayFab Unity SDK from here:

You have several download options on this page, but I would recommend downloading the regular 'PlayFab SDK'. The 'Editor Extensions' helper is a nice idea, which didn't work out the last time I've tried it, as it lost connection to PlayFab's server and the title quite often. So if you don't want to update the SDK every week, just go with the regular download.

After downloading, import the PlayFab SDK into your Unity project. For establishing the relation between the SDK and your title on PlayFab's servers, you will have to enter its title ID in the SDK settings. Locate the 'PlayFabSharedSettings' file in your project as shown below, then enter the title ID that has been generated for you in PlayFab's dashboard (see first screenshot in this thread).


Lastly, since the IAPManager needs to be aware that you are now going to use PlayFab features as well, you have to drag and drop our PlayfabManager prefab found under SimpleIAPSystem > Prefabs > Resources in the same scene like the IAPManager. If you don't do this, a temporary instance of the PlayfabManager (along with a warning message) will get instantiated so your app will continue working.

5.   Using receipt validation only

'Receipt validation only' means that in-app purchase receipts from your app will get sent to PlayFab for validation and approval, but you are not planning to use any other PlayFab features (cloud save, cloud scripts, analytics, product sales, and so on). In this case, open up the Plugin Setup editor under Window > Simple IAP System > Plugin Setup and choose 'Validation Only'. If you would like to use the full PlayFab suite by selecting 'Full Suite', you have to do the following steps as well.

Please make sure that you have first read and understood the concepts in the Receipt Verification chapter in our documentation PDF (included in Simple IAP System), and followed the section about Service Receipt Verification described there, specifically adding the ReceiptValidatorService component to your IAPManager prefab. This is necessary regardless of the PlayFab mode 'Validation Only' or 'Full Suite'.

For verifying real in-app purchase receipts, PlayFab needs some of your App Store secret keys to validate their authenticity for you. Head over to the Add-ons section, where you'll be able to find the platforms supported for receipt validation: Amazon (under Monetization), Apple and Google (under Platforms).

Click on the platforms you would like to use and enter the credentials necessary for receipt validation. If you've successfully activated them, they should show a green label saying that.

If you've followed the guide until now and only want to use receipt validation, you've made it! No other steps are required for you at this point.
Please play-test your game with 'Development Build' enabled and check that purchases are actually getting verified correctly.

On the other hand, if you are using the 'Full Suite' mode in our Plugin Setup window, then there are still a few steps waiting for you - please follow along until the end.

6.   Logging in the user in Unity

With PlayFab being in 'Full Suite' mode, our DBManager will not save any data locally on the device. This refers to the DBManager's 'Memory Only' mode, which is activated automatically for this, and means that players need to "download" their own data from the PlayFab servers each time your app is launched. This complies with a high-security app environment, as there is no local data or any save games regarding in-app purchases that could be tampered with.

However, this also means that players need a way to get their purchase data, and only their data, back whenever they launch the app. That's why users have to log in to the PlayFab servers using their account credentials (requiring an active internet connection), so they can continue playing where they left off. In order to do this, Simple IAP System provides a very basic login scene named 'UserLogin'.

At this state, users need to register with their email + password for creating their own account. This account should then be used in subsequent app sessions by logging in with the same credentials. A password recovery method is also provided, in case the user actually entered a valid email address he has access to.

An exception to this login technique are platforms which already have a common authentication system, such as Facebook and Steam. By design, users on these platforms are already signed in before they open the app. This is why instead of using the approach described above there too (effectively doubling the registration process), the existing authentication system is used to auto-login the user - they do not need to enter anything and their PlayFab account is connected automatically, even when logging in from different devices.

Remember, since the login scene should now be the first scene of your app, it needs to contain the IAPManager and PlayfabManager prefabs for initialization purposes, but also be declared as the first scene in your Build Settings:

7.   Feature Overview

Now that we've implemented PlayFab user management, in this chapter we're going to take a look at what we can do with that integration.

Receipt Validation
Receipt validation happens whenever users purchase a product in the shop. When using the 'Validation Only' mode, only purchases for real money are being validated at the time they happen - however, the result is not really synced with PlayFab, but directly saved to the device. In 'Full Suite' mode, both real money and virtual purchases, as well as the result (e.g. inventory and virtual currency balances) are synchronized with PlayFab - nothing exists locally on the device.

Validating purchases with PlayFab allows you to go into great detail about monetization, track purchase amounts across platforms and even inspecting single users on what they bought in your game. For a more aggregated summary on what your users are buying in your game, along with how often they do it, you can set up a query in the Analytics section for a bar chart analysis.

Cloud Save (Full Suite mode)
Since all transaction related actions are acknowledged by the PlayFab servers, they are registered on the user's PlayFab account. In the user's perspective this means that, combined with a login system described in the last chapter, users can switch devices, uninstall & reinstall the app, still retrieve their data and continue playing without any loss of data (more on synchronization in the next chapter). In an administrator's perspective (yours), having everything flowing over PlayFab's servers allows you to control virtual currency economies, modifying currency balances or inventory of hacking users, banning their accounts, giving out product keys as promotions or just looking at what your players are doing.

Introducing Sales (Full Suite mode)
Temporary sales for products could be a way to make specific items or purchases in general more appealing - the big benefit here is that you can introduce IAP sales without updating your app. If you know you would like to run sales in the future, just check 'Fetch' for both real money and virtual products in the IAP Settings editor.

What this does is not only fetching and displaying prices of real money products from the App Stores, but also downloading current prices from your title's economy catalog in PlayFab. So in order to run a sale for a specific product, just open it in PlayFab's catalog and edit its price. The new price will be effective when users relaunch your app.

8.   In-game Synchronization

Many game actions are automatically synchronized with PlayFab at the time they happen in your app. This applies to everything that requires an interaction with PlayFab's servers, basically. For example, these are the actions which get auto-synced:
  • user purchases real money product (product is assigned to inventory)
  • user purchases virtual currency (currency amount is updated)
  • user purchases virtual product (currency amount is updated, product is assigned to inventory)
  • user purchases virtual product with usage count (currency amount is updated, usage is updated in Player Data (Title))
  • user selects/unselects product (selection value is updated in Player Data (Title))

As you can see, most of the shop synchronization is handled for you already. What Simple IAP System cannot know though, is what you are doing with these items in your game. This means that everything dependent on your own game-specific use case also has to be handled and synchronized by you. The PlayfabManager (link to Scripting Reference) provides several methods, described below, for syncing your data back to PlayFab. Each method is explained with a sample use case and the point when it's best to call it.

Use case: the player finds a new weapon in-game and you would like to give it to him for free. Note that this method is best suited for non-consumable products, as for consumable products you should call the other methods directly to minimize web requests.
When: at any point during the game.

Use case: the player previously bought some power-ups with usage count. He then activates them in-game, which you are tracking via DBManager.IncreasePlayerData by passing in a negative value (to substract the power-up usage count). You then want to synchronize the remaining usage count with PlayFab by calling this method.
When: only at the end of a round or level, to minimize web requests.

Use case: the player collects coins during the game, which you are tracking via DBManager.IncreaseFunds. You then want to synchronize the current currency amount with PlayFab by calling this method.
When: only at the end of a round or level, to minimize web requests.

Use case: you have an in-game inventory display where players can select and deselect e.g. weapons. Note that the selection in the shop scene is synced for you already.
When: at any point during the game.

9.   Adding Cloud Scripts

Some of the methods listed in the previous chapters are calling custom code on PlayFab's servers, referred to as "cloud scripts". Each title on PlayFab has its own server code section, where you can execute actions which should not be in the hands of users (to prevent hacking), such as granting products or virtual currency, or just to add another security measure by checking the values it receives for feasibility. You have to add some server methods to your cloud script, so that Simple IAP System is able to properly call them for your title. On PlayFab's dashboard, go to Automation > Cloud Script and click on "Upload New Revision" at the top right corner.

Select the CloudScript.txt file included in SIS (SimpleIAPSystem > Scripts > Extensions > PlayFab) and check the box to make it live immediately after upload.

[yellowalert]You've made it to the end! As mentioned at the beginning, please note that development on the PlayFab integration is still in progress.
Your feedback on this guide or the integration in general would be much appreciated to further shape the direction of new features![/yellowalert]

Tanks Multiplayer / Guide: HOW TO - Integrate Simple IAP System
« on: June 19, 2017, 08:30:47 pm »
This guide explains how to replace the default shop in Tanks Multiplayer with Simple IAP System. The components used in this guide are directed at the multiplayer configuration using Unity Networking (UNET), but can be applied to a project set up for Photon networking in the same way.

Table of Contents
1. Problem description
2. Recreating the shop product prefab
3. Preparing the shop scene for Simple IAP System
4. Doing some code changes
1.   Problem description
You have set up your Tanks Multiplayer project as shown in the 'Getting Started' tutorial on our YouTube channel. After playing with the default project, you would like to integrate a more advanced shop solution, possibly supporting virtual currencies, localized prices or a complex database via Simple IAP System. Also, you have imported Simple IAP System and correctly configured it for a billing plugin of your choice (again, a tutorial can be found on our YouTube channel) already.
2.   Recreating the shop product prefab

Open the Intro scene of Tanks Multiplayer. The first thing we are going to do here is to create a new product prefab that can be used by Simple IAP System. Expand the Canvas > Shop > Window > Products game object and select one of the default shop products (e.g. ProductA). Remove its IAPProduct component and attach the IAPItem script instead.

All values of the IAPItem component will be empty in the inspector. Expand the product game object so you can see all of its UI elements and labels, then start assigning them to the IAPItem script in the inspector. The result should look like the following:


Lastly, you have to add OnClick listeners to the item buttons, so that they actually do something when pressed. On the buyButton, add a new listener and assign the IAPItem script on the root object, then choose its Purchase() method. On the selectButton, add a new listener and assign the IAPItem script on the root object as well, then choose its IsSelected() method at the top - note that there is another IsSelected() method in the dropdown further below, but you have to select the IsSelected() method under "Dynamic bool".


Drag & drop the modified product into the project panel in order to create a prefab. Give it a more descriptive name too, like Tank_IAPItem.

3.   Preparing the shop scene for Simple IAP System

Next, we are going to prepare the scene for our new shop. Delete all shop product game objects from the scene and only keep the "Products" game object. Remove its VerticalLayoutGroup component. Instead, attach a GridLayoutGroup and IAPContainer script to it.

Delete the "UnityIAP" game object from the scene (found under the "Managers" game object). We will not use that anymore, since the prefabs in Simple IAP System are a full replacement of it. Then, locate and drag & drop the prefabs of SIS into your scene: IAPManager, ShopManager, Window - Message. With the ShopManager selected, expand the "Window - Message" instance and assign it and its Text element to the ShopManager component in the inspector.

Open the IAP Settings editor (Window > Simple IAP System > IAP Settings) for creating your IAP product listing. You can delete all the unnecessary groups, only keeping one group for your IAPs as seen in the screenshot below. Please note the following points:
- our newly created item prefab is assigned in the "Prefab" slot
- our modified Products game object is assigned in the "Container" slot
- the identifiers of our tank products match the tank prefab names in our NetworkManagerCustom component (section "Registered Spawnable Prefabs"). This is so that we can map the player tank selection with our player prefabs via code later, for sending it across the network. If you have created different product identifiers on the App Stores, then you can map them in the "Platform Overrides" section per product.
- make sure that the type of your tank products are set to "Non Consumable"

4.   Doing some code changes

Since we have removed the UnityIAPManager and IAPProduct references from the scene already, we don't have to do any code modifications to them anymore. What we have to change is the default tank selection when players launch the game for the first time. Currently, this is done in the UIMain script, Start() method. To make use of Simple IAP System and grant players the free tank automatically whenever nothing is selected, we have to change:

Code: [Select]
if (!PlayerPrefs.HasKey(PrefsKeys.activeTank)) ...

Code: [Select]
if (!SIS.DBManager.GetAllSelected ().ContainsKey ("IAP"))
SIS.DBManager.SetSelected("TankFree", true);

Note that the string values above relate to your settings specified in the SIS IAP Settings editor window. "IAP" is the name of the group your tank products are located in, while "TankFree" is the identifier of the tank that should be granted for free.

Now that the default selection is set, and Simple IAP System handles the shop selection automatically, we still have to make the network aware of what the player selected. This happens in the NetworkManagerCustom script, GetJoinMessage() or AddPlayer() method (depending on the network solution used), where the selected prefabId is assigned to a join message. The join message expects an index value of the tank that is selected, so we first have to get the local selection again and convert it to the array index by comparing the player prefab names.

Note that you need to specify the IAP Settings editor group of your tank products in the DBManager.GetAllSelected() call again below. The final code looks like this:

Code: [Select]
//constructs the JoinMessage for the client by reading its device settings
private JoinMessage GetJoinMessage()
string selectedTank = SIS.DBManager.GetAllSelected()["IAP"][0];
int selectedIndex = 0;

for (int i = 0; i < singleton.spawnPrefabs.Count; i++)
if (selectedTank == singleton.spawnPrefabs[i].name)
selectedIndex = i;

        JoinMessage message = new JoinMessage();
        message.prefabId = short.Parse(selectedIndex);
        message.playerName = PlayerPrefs.GetString(PrefsKeys.playerName);
        return message;

Code: [Select]
//received from the master client, for this player, after successfully joining a game
void AddPlayer()
        string selectedTank = SIS.DBManager.GetAllSelected()["IAP"][0];
        int selectedIndex = 0;

for (int i = 0; i < playerPrefabs.Length; i++)
if (selectedTank == playerPrefabs[i].name)
selectedIndex = i;

        //get our selected player prefab index
        int prefabId = selectedIndex;

        //get the spawn position where our player prefab should be instantiated at, depending on the team assigned
        //if we cannot get a position, spawn it in the center of that team area - otherwise use the calculated position
Transform startPos = GameManager.GetInstance().teams[PhotonNetwork.player.GetTeam()].spawn;
if (startPos != null) PhotonNetwork.Instantiate(playerPrefabs[prefabId].name, startPos.position, startPos.rotation, 0);
else PhotonNetwork.Instantiate(playerPrefabs[prefabId].name,, Quaternion.identity, 0);
You should now be ready to go with Tanks Multiplayer + Simple IAP System! If you experience any billing related issues when testing on a real device, please have a look at our App Store guides and common errors over here.

Tanks Multiplayer / Guide: HOW TO - Add a new tank
« on: June 06, 2017, 09:20:27 pm »
This guide explains how to add a new tank and have it show up in the shop selection screen. The components used in this guide are directed at the multiplayer configuration using Unity Networking (UNET), but can be applied to a project set up for Photon networking in the same way.

Table of Contents
1. Problem description
2. Creating a new tank
3. Creating a new shop product
4. Assigning the tank to the network
1.   Problem description
You have set up your Tanks Multiplayer project as shown in the 'Getting Started' tutorial on our YouTube channel. After playing with the default project over multiplayer, you would like to customize the project and add your own tanks to it, which the player can buy/use during the game.
2.   Creating a new tank
The easiest way to create a new tank is to start with one of the existing tank prefabs as a base template, and swap out the model behind it. So that's what we are going to do in this step. I have created a very simple model I would like to use as a tank already, basically just consisting of several cubes. The important part is that when you are creating your own tank model, make sure that the turret is a separate game object so it can be rotated independently from the bottom of the tank. This is the model I am going to use in this guide.

Next, duplicate one of the existing tanks (e.g. 'TankFree'), located under TanksMultiplayer > Prefabs > Resources and give it a unique name. For this guide I'm going with 'TankSimple'. Note that this duplicate still contains all game objects and scripts like the original prefab at this point.

Drag the prefab into the scene and expand its game object hierarchy. The 'TankRenderers' game object is where the current model renderers are parented to. Since we want to use our own model, you can delete the 'TankRenderers' game object (which will break the prefab connection, but that's fine).


Now, locate your own model, drag it into the scene and make it a child of your current tank template object. Make sure that it is aligned & centered to the parent object nicely, i.e. in the center and above the shadow texture. Also, make sure that the model/prefab you have just added does not have any colliders attached to it. If it does, remove them. The only collider necessary should still be attached to the main object itself.

Locate the turret game object on the tank (or the deepest possible child object attached to it), and create a new empty game object. This new empty object will act as the shot position where bullets are getting spawned from. Name it 'ShotPosition' and move it to where you want it to be, typically at the front of your turret.

Finally, select your model game object and assign it to the 'Player' layer. If you get asked whether or not you want to include child objects, press 'Yes, change children'.


Your model is now set up correctly. But since we've deleted the old model on this tank template, some game object references are missing to the new model. Select the top-level tank game object containing all the important scripts.

You can read about the variable description in our Scripting Reference for the Player script. Assign the missing variables with the game objects from your new model. If necessary, resize the renderers array to fit all renderers that should go in there.


Press 'Apply' in the top right corner in order to save all of your changes back to the new tank prefab, and to complete this chapter.
3.   Creating a new shop product
Open the 'Intro' scene. Find the 'Shop' game object (under 'Canvas') and enable it, so we can see the contents of this UI element in the editor. Expand its hierarchy until you can see the product entries. This will be our starting point for this chapter.

Duplicate one of the existing product entries in the scene and give it a unique name, e.g. 'ProductD'. On its IAPProduct script, you should give it a unique identifier and (increasing) selection value as well. For this guide, I'm going to enter Id = 'tank_simple' and Value = '3' (because the last available selection value was 2, so the new tank will have selection value 3).

Note that if you are going to sell the tank in your shop for real money, the Id (identifier) should match with a product identifier you have created on the App Stores respectively. In this example, we'll just make the tank free, so we don't have to worry about any App Store configurations at this point. Uncheck the 'Buyable' checkbox to make the product free.

The product is now configured correctly, but the text is still showing values of the product we duplicated it from. Expand the game object hierarchy until you can see the description, title and icon sprite of this product entry. Feel free to modify these values with something more appropriate to describe your new tank (I'll leave the icon sprite as is).

To complete this chapter, disable the 'Shop' game object again and save the scene.
4.   Assigning the tank to the network
In this last chapter, we make the network aware of the new tank selection, which is available in the shop menu, by assigning it to our NetworkManagerCustom component and play-test the game to see it in action.

Open the 'Intro' scene. Select the 'Network' game object, so you can see the NetworkManagerCustom component. In its 'Spawn Info' setting and the 'Registered Spawnable Prefabs' section, click the little '+' to add a new row for your tank. Drag & drop the prefab you've created during this guide from the project panel, Prefabs > Resources folder, into that slot.

You're all set! Start the game and enter the shop - you should be able to select your new tank there (press the Select button). Then, close the shop and enter the game. There you have it - you are playing your new tank in the color of your team!


Tanks Multiplayer / Guide: Photon Server for LAN
« on: December 16, 2016, 03:30:34 pm »
This guide explains how to download/install and configure the Photon Server SDK for your own LAN.

Table of Contents
1. Problem description
2. Download and installation
3. Server configuration
4. Connection test
1.   Problem description
When using Unity Networking (UNET) in Tanks Multiplayer, playing over a private, local area network (LAN) is already possible and we greatly reduce your effort by providing LAN discovery for detecting open matches and joining them automatically - basically it just works. With Photon however, you need a dedicated server running in your LAN and enter its IP address in-game so others are able to connect to that.
2.   Download and installation
Head over to the Photon Server SDK page and download the latest Server SDK (should be on the left side, requires Windows). You don't need to register right now. After you've extracted the files somewhere on your harddrive, navigate to its "control center", found under deploy > bin_WinXX. Start up PhotonControl.exe.
3.   Server configuration
If you start up PhotonControl, you will receive a message that your server currently supports 20 CCUs. If you want more than that, sign up on the Photon website and download your 100 CCU license - for free. Move it into the folder where your PhotonControl executable is located and restart it to take effect.

Now, click on the PhotonControl icon in the tray bar and select 'Game Server IP Config'. Here you have to choose how your server should be reached. You can choose between your private IP within your LAN, or a public IP. Note that if you want to have players connected from a different network, you have to set a public IP that does not change i.e. a static IP. However for simple LAN setups, you would use a local IP - therefore click on 'Set Local IP'.

Lastly start the LoadBalancing application as shown below, which contains all necessary game logic for running Photon PUN clients with Unity.

4.   Connection test
Fire up the Unity Editor with Tanks Multiplayer configured for Photon. Open the 'Intro' scene and press play. Click on the settings button in order to select the NetworkMode LAN, which makes an additional field for the server IP visible. Replace "" with the local or public IP you have chosen under PhotonControl's 'Game Server IP Config'.

Close the settings window and press play - you should now be playing on your own server!
For more information, please refer to the official getting started guide on the Photon website.

Tanks Multiplayer / Release Notes
« on: November 11, 2016, 03:50:12 pm »
Subscribe to this thread to receive email notifications when a new version comes out.

As a registered user, click "Notify" in the top right corner of this post.

Simple IAP System / Guide: Other App Stores
« on: October 29, 2016, 04:26:07 pm »
While we try to provide step-by-step guides for most popular App Stores, we may not have guides for all platforms.

In this case, please refer to the following official App Store guides documented by Unity. You can ignore all code-related details in them, as Simple IAP System handles this for you already!

Windows Store
Amazon App Store
Samsung Galaxy
Apps Store
Tizen Store

Please let us know if you find something that seems to be incorrect, or needs additional explanation.

Tanks Multiplayer / Frequently Asked Questions
« on: August 15, 2016, 07:37:03 pm »
#1 I can't run the scenes included in this asset / networking doesn't do anything.
Please follow the first chapter of the provided documentation pdf. You will have to configure your project for networking first as described there.

#2 I'm getting errors referencing the UnityIAPManager related to missing purchasing scripts on import.
You've enabled Unity Analytics or IAP in Unity's service panel, but did not import its billing plugin. Open the Unity IAP service page again and press the shiny Import button.

#3 I'm getting errors referencing non-existent variables in the SceneManagement namespace such as 'sceneLoaded' or other API errors.
The minimum required version is Unity 5.4.0f3. If you are still getting errors on that or higher Unity versions, please contact us with more details.

#4 Players can't collide with each other. How do I enable it?
The collision between tanks is disabled on purpose. You can enable it in the physics matrix (Edit > Project Settings > Physics).

Simple IAP System / Guide: iOS App Store
« on: December 04, 2015, 02:25:08 pm »
This guide explains how to create and configure in-app purchases in iTunes Connect.

Table of Contents
1. Register developer account
2. Create your app in iTunes Connect
3. iOS deployment in Unity
4. Testing IAPs on your device

1.   Register developer account
Enroll in the Apple Developer Program. Please note the difference in requirements for individuals or organizations. There is a $99 yearly membership fee to be a publisher on iTunes.
Having issues in the registration process? Please see this page on Apple’s support pages.
Next, go to iTunes Connect and accept the paid contracts listed under the Agreements, Tax and Banking section.
Agreeing to these contracts is required in order to sell apps or in-app purchases.

After requesting and confirming the contract, you will have to edit its Contact, Bank and Tax Info for it to get reviewed by Apple.

2.   Create your app in iTunes Connect
In this step we will setup necessary certificates for your account and create a new app in iTunes Connect with in-app purchases.

2.1 Create Certificates, App IDs & Provisioning Profiles
To build your app in Xcode and publish it to the App Store later on, you will need to create certificates and provisioning profiles. This is a great resource with step-by-step instructions (follow step 2 only).

2.2 Create app
In iTunes Connect, open the My Apps section and add a new iOS app.

On the next window, fill out the required information about your app, such as its name, primary language and bundle ID.

2.3 Create in-app purchases
In the In-App Purchases tab under Features, add a new product.

You will see a list of available purchase types – consumables, non-consumables and subscriptions. Read each description carefully if you are unsure about the type you need. Make sure the information selected here matches with your product details entered in our IAP Settings editor. You will not be able to change the type or identifier of a product afterwards.

Note: Apple will reject your app if you don’t provide a way for users to restore their transactions. Keep the restore product in your IAP Settings editor and Simple IAP System will handle everything else for you (do not create an additional product in iTunes).

2.4 Add test accounts
In the Users and Roles section, switch to the Sandbox Testers tab and add a new tester entry. You don’t have to add an email address which really exists, but you have to remember its login information. If you add multiple testers with different store settings, you can even test your in-app purchases in several store languages.

3.   iOS deployment in Unity
Here we will prepare our application in Unity for the iOS platform.

3.1 Enter bundle identifier
Switch to the iOS platform (File > Build Setting) and open the Unity settings for iOS by pressing Player Settings.

In the Other Settings section, change the bundle identifier to what you like it to be, but keep the format of If you already have an app on iTunes Connect, make sure that the bundle identifier here is the same as displayed for your app in the Developer Console.

3.2 Check bundle version
The bundle version in the Unity settings for iOS will default to 1.0 for new apps, which is fine for now. If you’ve published an app on iTunes already, replace this with its associated bundle version from iTunes Connect (App Details section, see last screenshot).

3.3 Build app
First, enable Development Build under File > Build Settings. This enables log messages sent by Simple IAP System on your device for debug purposes. Don’t forget to disable Development Build for your live apps. Next, if you would like to get an impression of the sample shop scenes included in SIS, add the example scenes to the build. Then deploy your app to Xcode by pressing Build (on a Mac). After the project export has finished, open the produced *.xproj file with the latest version of Xcode.

In Xcode, check that the StoreKit framework has been added correctly in the Linked Framework and Libraries section on the General view (3rd party billing plugins only). If StoreKit.framework is not to be found, add it manually by clicking on the plus symbol.

4.   Testing IAPs on your device
Before deploying the app on your device, open its settings and sign out with your Apple ID. This is necessary to receive the login popup later, when doing a test purchase.

Press Run in Xcode to deploy and start the application on your connected iOS device. If you have changed values in the IAP Settings editor of Simple IAP System, you need to uninstall your app from the device before building and deploying it via Xcode again. A message should show up, indicating that the build has succeeded. In case your build fails, you most likely have errors in your plugin dependencies to solve.

When the app has started on your device, enter your shop scene and try to purchase a product. Log in with your sandbox test account details when prompted. If it does not prompt for your Apple ID, check if you are really signed out in device settings.


Simple IAP System / Guide: Google Play
« on: December 04, 2015, 12:07:00 pm »
This guide explains how to create and configure in-app purchases for Google Play.

Table of Contents:
  • Register developer account
  • Create your app in Google Play
  • Set up Google Merchant account
  • Android deployment in Unity
  • Upload & publish your app in Google Play
  • Testing IAPs on your device

1. Register developer account

Login using your Gmail account and register your Google Play developer account.
There is a $25 one-time registration fee to become a publisher on Google Play.

Having issues in the registration process? Please see this answer on Google’s support pages.

2. Create your app in Google Play
In this step we will create a new app in Google Play with in-app purchases.

2.1 Create app
In case you’ve opened the Developer Console for the first time, you will see an overview of actions. Start with publishing a new app.

Fill out the required fields (with your app title) and press on “Prepare Store Listing”. We will upload an APK later.

Fill out all required fields, upload some screenshots (you can use blank images/templates) and save your listing. The checkmark next to the Store Listing tab will be highlighted in green after you have entered every information necessary.

2.2 App pricing
Do the same with the Content Rating tab, by going through the wizard provided and complete the content rating questionnaire.

Next, switch to the Pricing & Distribution tab and specify your desired app pricing strategies. After this step, both Content Rating and Pricing tabs should be highlighted in green.

2.3 Create in-app purchases
In the In-app Products tab, add a new product.

Add a new managed product (for consumable and non-consumable products) or subscription to your app. The Product ID is a unique identifier for this in-app purchase, which you have entered in Simple IAP System’s IAP Settings editor (e.g. coins, no_ads etc.).

Enter the required fields for declaring this in-app purchase. Afterwards, press save and set the product to Active.
Note: If you add translations for your products, Simple IAP System is able to display product details in the user’s native language, which naturally increases IAP conversion rates (recommended).

At this point, you should now have the exact same IAP information available in Google Play and in our IAP Settings editor.

3. Set up Google Merchant account
To sell priced apps and in-app purchases, you will need a Google Merchant account to receive payments. Google Merchant supports various countries and can be configured right in the Google Play Developer Console. For a detailed list of supported countries and steps to do, please see this entry on Google’s support pages.

4. Android deployment in Unity
Here we will prepare our application in Unity for the Android platform.

4.1 Enter Google Play license key
Your license key is the unique identifier for your app and prevents unauthorized access. You can find it in the Google Play Developer Console, under All applications > Services & APIs.

Copy the full key and switch to the Unity project. Locate the IAPManager prefab in the project panel (Simple IAP System > Prefabs > Resources) and insert this license key into the Google Store Key field.

If you are using a 3rd party billing plugin, it is very likely that you cannot find this field on the IAPManager prefab. In this case, please open the settings window of the billing plugin you are using and enter the key there. Here is an overview of where they key field is located:

Unity IAP: IAPManager prefab
Prime31: IAPManager prefab
Voxel Busters: Window > Voxel Busters > NativePlugins > Select NPSettings. Billing Settings > Android > Public Key.
Stan's Assets: Window > Stan's Assets > Android Native > Edit Settings. Billing Settings (third tab) > Base 64 Key.
SOOMLA: Window > Soomla > Edit Settings. Android Settings > Billing Service Selection > Google Play > API Key.

4.2 Enter bundle identifier
Switch to the Android platform (File > Build Setting) and open the Unity settings for Android by pressing Player Settings.

In the Other Settings section, change the bundle identifier to what you like it to be, but keep the format of If you already have an app on Google Play, make sure that the bundle identifier here is the same as displayed for your app in the Developer Console.

4.3 Check bundle version
The bundle version and bundle version code in the Unity settings for Android will default to 1.0 / 1 for new apps, which is fine for now. If you’ve published an app on Google Play already, replace this with their associated bundle version and version code from the Developer Console (on the APK section).

4.4 Modify AndroidManifest (3rd party billing plugins only)
You can skip this step if you are using Unity IAP.
3rd party billing plugins usually come with an AndroidManifest.xml file, which contains necessary Android activities and permissions used by the plugin – such as android.permission.INTERNET, and so on. These are displayed when the user tries to install your application on his device. After importing such an Android plugin, the AndroidManifest.xml file would be located under Plugins > Android in your project panel. All of our supported billing plugins are modifying this file automatically for you, you only have to make sure that billing is enabled in the plugin you are using.

4.5 Create Keystore
If you didn’t publish an app before, you probably didn’t create a Keystore yet. To do so, open the Unity settings for Android (File > Build Settings > Player Settings) and expand the Publishing Settings. Enable Create New Keystore, enter your password (twice) below and in the Key Alias, select Create a new key. A new window opens – enter the necessary information. Save this Keystore somewhere safe! If you lose your Keystore, you cannot submit app updates in Google Play anymore.
If you would like to use an existing Keystore, choose Browse Keystore and enter your Keystore password, then select the Alias and enter the same password again.

4.6 Build app
Build your app by pressing Build (File > Build Settings). We are only going to save the APK file created in this process on the hard drive (and not using Build And Run), because Google Play still needs some settings to be configured first.

5. Upload & publish your app in Google Play

5.1 Upload APK

Go to the APK section in Google Play and upload your newly created APK file in the Alpha testing stage.

5.2 Publish app

After filling out each tab and uploading the APK, each section should be completed (green) and the status shown as Ready to publish.

You are now ready to publish your app. Don’t worry: because you’ve uploaded an alpha or beta build, the app will not be visible publicly – only for you to test it. Select the status and choose Publish this app. The publishing process can take up to 24 hours before it is available for your testing needs.

5.3 Add test accounts

Under Settings, go to the Account details tab and add your Gmail account for testing access. To test in-app purchases, you will have to add an email address which is NOT the email used to register your Google Play Developer account and then add this email on your device. Otherwise, you will get the error message "The publisher cannot purchase this item".

6. Testing IAPs on your device
After you've waited the ~24 hour submission approval for your app on Google Play, go back to Unity and open the Build Settings (File > Build Settings). First, enable Development Build. This enables log messages sent by Simple IAP System on your device for debug purposes. Don’t forget to disable Development Build for your live apps. Next, if you want to test your app with the example scenes, you have to add them to your Build Settings. Finally press Build And Run to deploy your project to your connected Android device. If you change values in the IAP Settings editor of Simple IAP System later, you need to uninstall your app from the device before deploying it again.

When the app has started on your device, enter your shop scene and try to purchase a product. Log in with your test account when prompted. If it does not prompt for your Google Play account, go to your Google Play device settings and disable automatic password completion in the authentication options. Purchasing a product in your app should show the following popup:


Simple IAP System / Frequently Asked Questions
« on: October 20, 2015, 11:22:21 pm »
#1 The debug log or popup on the device says that billing is not supported/item could not be found/authentication is required.
One reason could be that your bundle identifier in Unity does not match with the one on the App Store. For Google Play, your developer key must be entered in the IAPManager prefab and your app has to be published as alpha/beta build (takes up to 24 hours). Also you must be logged in as a test user on the device (test account added in Google Play/iTunes).

#2 I’m getting an "This version of the application is not configured for billing" error.
In addition to #1, on Google Play your AndroidManifest file in Unity must contain the permissions and activities needed for your billing plugin to work. Please refer to your billing plugin manual about which activities are required. If you are using Unity IAP, this is done automatically. After that, you have to upload your build APK with the correct bundle version/code to Google Play.

#3 The Shop Manager says that it could not find the IAPManager prefab.
Please start from the very first scene of your game, where the IAP Manager prefab is located.

#4 Can I have both IAPManager and ShopManager in the same scene?
If there is only scene in your project - yes. Otherwise the IAPManager prefab should go into the first (e.g. loading) scene, and the ShopManager prefab in your shop (e.g. main) scene.

#5 Where do I set up the IAPItem prefabs and parent containers in my shop?
The connection between IAPItem prefabs and where they get instantiated - as childs of the containers - is saved in the ShopManager prefab on a per-scene basis. If you open the IAP Settings editor without ShopManager prefab in your current scene, you won't be able to see these properties. Add a ShopManager prefab to your scene and reopen the IAP Settings editor to reveal them.

#6 My shop items do not show up.
Make sure that your prefabs and parents are assigned in the IAP Settings editor (Window > Simple IAP System > IAP Settings). Also, SIS can't receive the product list if there are errors in your billing setup. See #1 and #2 for reference.

#7 My shop items are duplicated.
Make sure that the IAPManager prefab is only placed in the first scene of your app and that you start your game from there.

#8 I want to reset my non-consumable purchases, so I can start testing the same products again.
You can use the "Clear Database" button (or its code) from the „AllSelection‟ sample scene to wipe the product database. If you repurchase the product now, a "product already owned" message will show up - this is totally fine and will behave like a new purchase! Optionally on Google Play, you can cancel the purchase in Google Payment Merchant center as described here and wait for a refresh (few hours) or clear both the cache of your Google Play app and Google Play services on the device manually.

#9 How do I customize and modify visual elements of an IAPItem UI prefab?
IAPItem prefabs consist of various Unity UI elements. You can find manuals and tutorials on the official site. Drag the prefab under a Canvas gameobject in the scene (create one if necessary), make your changes and apply them.

#10 I want to have the same size for shop items on all devices, regardless of the screen resolution.
In Simple IAP System, UI elements are using pixel-perfect textures for best readability. You are looking for Unity's Canvas Scaler component (Scale With Screen Size). Attach it to your canvas in the shop scene. If you're using one of the sample shop scenes, find all UIPanelStretch components on the Container gameobjects and set both "Max Cell Size X/Y" to 0.

#11 The title/description/price is different in Unity or gets overwritten when I launch the app on a device.
For in-app purchases, your offline price gets overwritten with the localized app store price after initialization. Uncheck "Fetch" in the IAP Settings editor if you don't want to use the localized price (not recommended, because players should see prices in their local currency).

#12 Can I create my own button to purchase products and not use item prefabs?
Sure. You can write a short script for your button which calls SIS.IAPManager.PurchaseProduct(string productId) directly.

#13 What's the best way to upgrade to a new version of Simple IAP System?
When you upgrade to a new version, you probably want to keep your IAPManager prefab (saves products in the IAP Settings editor) and the IAPListener script (your product callbacks). On the import prompt, uncheck both of them and overwrite the rest. You still have to run the billing plugin setup afterwards (Window > Simple IAP System > Plugin Setup) and uncheck both of these again, if applicable.

#14 The IAP Manager can’t find my remote configuration file for overwriting in-game content.
If you have verified that the file is actually located on your server, check that the "Server Url" field on the IAP Manager follows the pattern, with the file name being e.g. remote.txt.

NavMesh Extension / Release Notes
« on: April 16, 2014, 01:46:04 am »
Subscribe to this thread to receive email notifications when a new version comes out.

As a registered user, click "Notify" in the top right corner of this post.

3D Tower Defense Starter Kit / Release Notes
« on: February 24, 2014, 11:38:52 pm »
Subscribe to this thread to receive email notifications when a new version comes out.

As a registered user, click "Notify" in the top right corner of this post.

Pages: [1] 2