Quantcast
Jump to content

Want to Publish Games on Galaxy Store using UDP?


Recommended Posts

2021-06-07-01-banner_v2.jpg

Unity Distribution Portal (UDP) lets you distribute your games to multiple app stores through a single hub. UDP repacks your Android build with each store’s dedicated In-App Purchase SDK to make your game compatible with the separate app stores (Android alternative app stores). In this tutorial, you will learn the procedure for publishing a game on Galaxy Store using the UDP console. All you need to do is implement in-app purchases (IAP) using UDP. UDP then automatically repacks your game into store-specific builds. Follow the tutorial to integrate UDP into your game and publish it on Galaxy Store.

Before you start

We recommend that you implement UDP in your game towards the end of the development cycle. It is easier to implement UDP at this stage as you have already decided what your game’s IAP items are. Make sure you have completed your game before diving into the UDP implementation. We have developed a sample coin collecting game (see Figure 1) in Unity and we’ll show you how we implemented UDP into this game.


2021-06-07-01-01.jpgFigure 1: Preview of the sample game developed in Unity.


Note that there are three types of Samsung IAP items: consumable (single use, re-purchasable), non-consumable (unlimited use, not re-purchasable), and subscription (unlimited use while active). Since UDP does not support subscriptions, there is no guidance for implementing subscription items in this post.

Now that you know when to implement UDP and which Samsung IAP items are supported, we’re ready to begin with the development procedure.

Create a game in the UDP console

After signing in to UDP, please follow the steps below:

  1. Go to My Games -> ADD GAME, enter the game title, and click on CREATE. After that, you are automatically moved to the Game Info tab.
  2. In the Game Description tab, provide some basic information (metadata, description, visual assets, and ratings).
  3. Click on SAVE. You are not required to complete all sections at this time.

Integrate UDP in Unity and link it to the UDP console

There are two ways to integrate UDP in Unity: using the UDP package or Unity IAP. We used the UDP package for this blog. To do this, follow the steps below:

  1. In the Unity editor, go to Window -> Package Manager, select All packages -> Unity Distribution Portal -> Install.
  2. To enable UDP in your project, access Window -> Unity Distribution Portal -> Settings.
  3. Create a new Unity project ID (if required, or else use an existing one) in the Services Window. To do this, click on Go to the Services Window, select your organization, and then click Create.
  4. Obtain the client ID from the UDP console: go to the Game Info tab of the UDP console, scroll down to Integration Information, and copy your Client ID using the COPY button.
  5. Now, go back to Window -> Unity Distribution Portal -> Settings, paste the client ID into the relevant field, and finally click on Link Project to this UDP game.

Now you have successfully linked your Unity project to the game created on the UDP console. If you’re having problems, go here to try some troubleshooting methods before jumping into the next section.

Register IAP items in UDP

There are two IAP products in our sample game: “Super Jump” (consumable) and “Upgraded Player” (non-consumable). We need to add these products in the UDP console so they can be purchased inside the game. We can register the items directly either on the UDP console or in the Unity editor.

Follow the steps below for the UDP console:

  1. Go to the Game Info tab of the UDP console, scroll down to In-App Purchases, and select Add Item. Do not forget to click on EDIT INFO, if required.
  2. Provide a valid product ID, product name, price (USD), and description. Select if the item is consumable or non-consumable, then click SAVE. You can add as many products as you have in your game. For our sample game, we have added a consumable and a non-consumable item with the product IDs “superjump1” and “upgradeplayer1” respectively. Please remember the IDs you choose as these are required while initiating purchases.
  3. You can manage the prices in different currencies for each product individually by clicking on Manage amounts and currencies. You can also automatically convert your base price (USD) to different currencies for all your products at once by clicking Convert.
  4. Select SAVE in the top right corner to save your changes.
  5. In Unity, go to Window -> Unity Distribution Portal -> Settings, and click on Pull to retrieve your saved IAP items from the UDP server. Now, you can see all the items are added to the IAP Catalog.

You can also add IAP items in Unity directly in the IAP Catalog by clicking on Add New IAP Product, and then selecting Push to save your products to the UDP server (see Figure 2). In addition, there are many manipulation processes for adding IAP items (for example, bulk import and CSV template). Click here to learn more.


2021-06-07-01-02.jpgFigure 2: IAP Catalog under UDP Settings in Unity.


Initialize the UDP SDK in Unity

To access the UDP SDK, we need to declare the UDP namespace inside the game manager script. Please note that “player.cs” is the manager script in our sample project and is attached to the main player game object in the editor as a component. Hence, from now on we continue editing the codes into this script to enable all the UDP functionalities. Follow the steps below:

  1. Add the following line at the beginning to access the UDP libraries.

    using UnityEngine.UDP; 
    
  2. Make the manager code (player.cs) inherit from the IInitListener interface.

    public class player : MonoBehaviour, IInitListener
    
  3. In the Start() function of the manager (player.cs) class, call the Initialize() method.

    StoreService.Initialize(this);
    
  4. The IInitListener then returns a success or failure message to inform your game if the initialization was successful. Implement the following methods in the same class to obtain this message: if it is successfully initialized, the OnInitialized() method is invoked with the user information; if it was not initialized, the OnInitializeFailed() is called with an error message.

    public void OnInitialized(UserInfo userInfo){
          Debug.Log("Initialization succeeded");
         // You can call the QueryInventory method here to check whether there are purchases that haven’t been consumed.  
    } 
    public void OnInitializeFailed(string message){
         Debug.Log("Initialization failed: " + message);
    }
    

If you’d like more guidance, check out Initialize the UDP SDK in the Unity documentation for more detailed information. Otherwise, continue to the next section.

Query the purchased IAP items

After the initialization is successful, we need to retrieve the previously purchased non-consumable and unconsumed products when the user launches the game. Call the QueryInventory() method of the UDP SDK to get the product information (product name, ID, description) for non-consumable purchases and consumable purchases that have not yet been consumed. Follow the steps below:

  1. It is necessary for the manager script (player.cs) to inherit the IPurchaseListener interface along with the IInitListener to implement the QueryInventory() method.

    public class player : MonoBehaviour, IInitListener, IPurchaseListener
    
  2. After that, we need to override all the required methods for the IPurchaseListener interface in our class. Although we show only the OnQueryInventory() and OnQueryInventoryFailed() methods here, we gradually complete the others in subsequent sections.

    public void OnQueryInventory(Inventory inventory){
          //Query inventory succeeded
          Debug.Log("Query inventory succeeded");
          IList<ProductInfo> productList = inventory.GetProductList();
          if(productList != null){
              for(int i=0; i<productList.Count;i++){
                   if(productList[i].ProductId=="upgradeplayer1"){
                       playerMaterial = Resources.Load<Material>("UDPMaterial");
                       MeshRenderer meshRenderer = GetComponent<MeshRenderer>();
                       meshRenderer.material = playerMaterial;
                   }
              }
          }
    }
    public void OnQueryInventoryFailed(string message){
          Debug.Log("Query Inventory failed");
    }
    

    As you can see, a few actions have been taken inside the method depending on the product ID. Similarly, you can build some logic here (for example, check for unconsumed products and purchased products that have not been delivered) based on your game design.

  3. Finally, call the QueryInventory() method on a successful initialization inside the OnInitialized() method that was implemented in the previous section.

    public void OnInitialized(UserInfo userInfo){
           Debug.Log("Initialization succeeded");
           // You can call the QueryInventory method here to check if there are purchases that haven’t been consumed.  
           StoreService.QueryInventory(this);
    }  
    

For further information about query inventory in UDP, go here.

Purchase IAP products

In our sample game, there are two UI buttons (see Figure 1), the “Buy Super Jump” and the “Upgrade Player.” These buttons allow users to purchase consumable and non-consumable items respectively inside the game. Please follow the steps below to accomplish these button actions:

  1. Declare two button variables in the beginning of the player class (player.cs).

    public Button buySuperJumpButton;
    public Button upgradePlayerButton;
    
  2. Add two listener methods, OnBuySuperJumpButton and OnUpgradePlayerButton, at the end of the Start() method of the player class (player.cs).

    buySuperJumpButton.onClick.AddListener(OnBuySuperJumpButton);
    upgradePlayerButton.onClick.AddListener(OnUpgradePlayerButton);
    
  3. Implement two listener methods in the same class for the button listeners in the previous section. These enable the “Buy Super Jump” and “Upgrade Player” buttons to initiate purchasing the respective IAP items through invoking the Purchase() method of the UDP SDK. Please note, we have used the item IDs we registered in the “Register IAP items in UDP” section.

    void OnBuySuperJumpButton(){
           //initiate purchasing a super jump item
           StoreService.Purchase("superjump1", "", this);     
    }
    
    void OnUpgradePlayerButton(){
           //initiate purchasing an upgraded player item
           StoreService.Purchase("upgradeplayer1", "", this);
    }
    
  4. The overriding method OnPurchase() is triggered if the purchase is successful. In other cases, the OnPurchaseFailed() method is invoked with an error message. If the item is consumable, consume the product here. Otherwise, deliver the product.

    public void OnPurchase(PurchaseInfo purchaseInfo){
                // The purchase has succeeded.
                // If the purchased product is consumable, you should consume it here.
                // Otherwise, deliver the product.
                if (purchaseInfo.ProductId == "upgradeplayer1"){
                     playerMaterial = Resources.Load<Material>("UDPMaterial");
                     MeshRenderer meshRenderer = GetComponent<MeshRenderer>();
                     meshRenderer.material = playerMaterial;
                }
                else if(purchaseInfo.ProductId == "superjump1"){
                            StoreService.ConsumePurchase(purchaseInfo, this);
                }
    }
    
    public void OnPurchaseFailed(string message, PurchaseInfo purchaseInfo){
                Debug.Log("Purchase Failed: " + message);
    }
    
  5. Save the script and go back to the Unity editor to add references for the UI buttons to the variables of the “player.cs” script that we declared in step 1.

We have completed purchasing IAP items inside our game. However, notice that in step 4, we only delivered the non-consumable item and invoked the ConsumePurchase() method for the consumable item.

Consume IAP products

We need to implement the overriding OnPurchaseConsume() and the OnPurchaseConsumeFailed() methods in the IPurchaseListener interface to consume and deliver the consumable IAP items. See the implementation below:

 public void OnPurchaseConsume(PurchaseInfo purchaseInfo){
            // The consumption succeeded.
            // You should deliver the product here. 
            if (purchaseInfo.ProductId == "superjump1"){
                superJump++;
            }
}

public void OnPurchaseConsumeFailed(string message, PurchaseInfo purchaseInfo){
            // The consumption failed.
}

We have delivered the “Super Jump” item by increasing the counting value. You can implement your game logic here according to your game design. Look here to find out more about consuming IAP products.

Validate in-app purchases

UDP performs client-side validation automatically. When a user purchases an IAP product, Galaxy Store returns the payload and signature. The UDP SDK then validates the signature. If validation fails, the purchase fails accordingly. You can also validate purchases on the server-side. See validating purchases on the server side to implement this functionality.

Build and test your game

Before building your game, add a UDP sandbox tester to verify that your IAP implementation is working. Go to Window -> Unity Distribution Portal -> Settings -> UDP Sandbox Test Accounts -> Add new test account, provide a tester’s email and password, and finally, don’t forget to click Push to save the update to the UDP server.

Now build an APK by going to File -> Build Settings -> Android -> Build and providing all the necessary basic information in Player Settings (File -> Build Settings -> Player Settings). For more information on building for Android, see Building apps for Android. After successfully building the APK, deploy it to the tester’s Galaxy device and assess the IAP functionality. Next, check the test status in the UDP console by going to the Game Info tab and then scrolling down to Sandbox Testing.

Publish your game on the UDP console

Once you have finished building and testing your game, upload the binary to the UDP console (Game Info -> Binary). Finalize all the game information (Game Description, Ads, Premium Price, App Signature) and then release the game by clicking RELEASE before publishing.

Go to the Publish tab on the UDP console, sign in to Galaxy Store with your commercial account, and then publish your game after UDP has successfully repacked it. You can later check the submission status in the Status tab of the UDP console. See details about publishing games on the UDP console here.

Conclusion

This tutorial demonstrates the entire process of publishing a game on Galaxy Store through the UDP console. It also uses the UDP package instead of Samsung IAP for integrating IAP into the game for Galaxy Store. UDP then repacks the game with the Samsung IAP automatically before it is submitted to Galaxy Store. Therefore, we hope this tutorial encourages you to develop games in Unity and publish on Galaxy Store easily through UDP Console.

Additional resources on the Samsung Developers site

This site has many resources for developers looking to build for and integrate with Samsung devices and services. Stay in touch with the latest news by creating a free account or by subscribing to our monthly newsletter. Visit the Marketing Resources page for information on promoting and distributing your apps. Finally, our developer forum is an excellent way to stay up-to-date on all things related to the Galaxy ecosystem.

View the full blog at its source

Link to post
Share on other sites


Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Similar Topics

    • By STF News
      The Galaxy Store Seller Portal team has brought forth new enhancements for May.
      Don’t miss out on valuable information about Galaxy Store Seller Portal
      In the past, important changes and the latest news about Seller Portal were shared through announcements posted on the Seller Portal system. Now, you can receive these announcements directly through email notifications.
      Email notifications contain valuable insights and information about Seller Portal. You will still continue to receive important announcements about the latest updates to Seller Portal, but now you can opt in and subscribe to receive benefits, tips, and news focusing on you, the seller.
      Change your email notification preferences at any time from your Seller Portal user profile. Subscribe now and don't miss any of the valuable information from the Galaxy Store Seller Portal team.

      Import beta app
      After beta testing your app, if no updates are required, you don’t need to upload the binary again. Instead, you can import the existing binary you used for beta testing to quickly register it for commercial distribution. From the Binary tab, click Import Beta App.


      App groups
      An app and its beta test apps are organized and displayed together as a group in your list of apps. You can easily identify which app is on sale in Galaxy Store or is being registered and if any apps were added as beta test apps. The group can be expanded or collapsed.

      Watch face keywords
      A new field for watch face keywords has been added for watch face apps (when "Watch faces" is selected as the category). Previously, we asked you to add keywords used on your watch faces in the Description field. This information is used to help us more quickly review your designs and identify any possible IP infringement.
      In the App Information tab of your watch face app, the Watch Face Keywords field is used for you to identify all words (such as your brand name) that appear on your watch face design. Text for commonplace terms, such as the names of days or months, do not need to be included.

      Promotional opportunities for Galaxy Store
      While discovering apps, a user may download an app based on various factors such as the app name, icon, screenshots, or description. Screenshots are one of the most important assets and can be used to make a big impact and visual impression.
      Did you know that your uploaded screenshots may be used for a banner in Galaxy Store? If you upload an image with a 16:9 ratio, the Galaxy Store team can immediately consider it for their promotions.

      Have you tried out last month’s updates to beta testing?
      Last month, enhancements to beta testing included testing any app at any time and running open and closed beta tests simultaneously, improving your ability to find and fix issues with your app before publishing in Galaxy Store. Read more about these added features in Enhancements for Beta Testing Apps in Seller Portal.
      Additional resources on the Samsung Developers site
      This site has many resources for developers looking to build for and integrate with Samsung devices and services. Stay in touch with the latest news by creating a free account or by subscribing to our monthly newsletter. Visit the Marketing Resources page for information on promoting and distributing your apps. Finally, our developer forum is an excellent way to stay up-to-date on all things related to the Galaxy ecosystem.
      View the full blog at its source
    • By STF News
      Galaxy Store is one of the top app stores to sell your Android games in many different countries. You can also sell various in-app purchase (IAP) items inside your games using the Samsung IAP SDK. As many of you now use the Unity engine to develop your games, Samsung has introduced a Unity plugin for the Samsung IAP SDK that enables you to implement IAP features. Follow the steps outlined in this blog to easily implement the Unity plugin into your project and utilize the Samsung IAP functionalities.
      Prerequisites
      It is assumed you are already familiar with the Samsung IAP procedure. If not, please read the IAP Helper programming guide carefully before proceeding further. After that, download the Samsung IAP Unity plugin package and go through its documentation. To avoid compatibility issues, make sure you meet the system requirements.
      There are three types of IAP items:
      Consumable: can be used only one time and re-purchasable Non-consumable: can be used any number of times and not re-purchasable Subscription: can be used any number of times while it is active For this example, we have developed a basic coin collecting game in Unity for Android and added UI buttons that allow users to buy IAP items (consumable and non-consumable) and a subscription. The “Buy Super Jump” button initiates purchasing a super jump item from Galaxy Store using the Samsung IAP SDK. Super jump is a consumable item which enables the player to jump higher than normal. Similarly, the “Upgrade Player” button initiates purchasing a player upgrade, which is a non-consumable item. This blog only covers consumable and non-consumable purchases, we’ll discuss subscriptions in a future blog.

      Figure 1: Preview of the sample game developed in Unity.

      Note: You are required to develop your game/application in Unity beforehand to integrate the IAP Unity plugin into it.
      Integrate the Samsung IAP Unity plugin
      After creating the game in Unity, you need to enable Samsung IAP functionalities in your project. Follow the steps below:
      Import the Samsung IAP Unity plugin package into the project. In Unity, click Assets -> Import Package -> Custom Package and select the downloaded plugin package. You can now see the Plugins folder under your Assets folder and the “SamsungIAP.cs” script at Assets/Plugins/Script. Copy or move the “SamsungIAP.cs” script into the default scripts folder of your project (where all the scripts are kept together) so that other scripts can access it easily. If you don’t already have a scripts folder, create a new one and keep all your project scripts together along with “SamsungIAP.cs.” Create an empty game object in the Hierarchy tab and drag-and-drop the “SamsungIAP.cs” script onto it. In our sample project, we have renamed the game object as “SamsungIAP.” Click on the “SamsungIAP” game object and check if the IAP functionality is enabled in the Inspector, as shown below:
      Figure 2: Samsung IAP is enabled for the project.

      Set the IAP operation mode
      IAP supports three operational modes. The production mode is for enabling billing for item purchases and the other two are for testing IAP functions without billing the game users for item purchases. The default operation mode is set to OPERATION_MODE_TEST with the return value as Success, but you can set the return value to Failure instead, or switch to OPERATION_MODE_PRODUCTION by checking (√) the Production Build checkbox in the Inspector as shown in figure 2. You can learn more about the IAP operation modes and how they work from here.
      Register the game and IAP items in Seller Portal
      To process/test the Samsung IAP operations, both your game and any IAP items need to be registered in Seller Portal. Follow the steps below:
      Ensure you have switched the platform of your game to Android and the package name is different from the apps registered in other app stores. You can rename the package name of your project from Player Settings -> Other Settings. Save your Unity project and build the APK file. In Unity, go to File -> Build Settings and then click the Build button. Follow the steps listed in Register an app and in-app items in Seller Portal and complete the registration of your game and IAP items accordingly. For our sample game, we have registered a consumable and a non-consumable item with the IDs “BuySuperJump” and “BuyUpgradedPlayer” respectively. Keep the item IDs in mind as they will be required when initiating the purchases. You can add testers (non-licensed and licensed) in the Binary tab of Seller Portal while registering your game in the manner covered in the previous step. Licensed testers are not charged for purchasing any IAP items. You can register the licensed testers in your Seller Portal profile. See IAP Testing for more information. Get previously purchased items
      Make sure to retrieve any previously purchased non-consumable and unconsumed items every time the user starts the game. Use the GetOwnedList() method of the IAP plugin to get information about the items the user has already purchased. However, please note there is a script called “player.cs” in our project which is added to the main player game object as a component. From now on we will be editing the code in “player.cs” to enable all the Samsung IAP functions for this project. Follow the steps below:
      Add the following line at the beginning to access the Samsung IAP libraries in this script.
      using Samsung; Call the GetOwnedList() method whenever the game launches by adding the following line at the beginning of the Start() method. Learn more about the GetOwnedList() method here.
      SamsungIAP.Instance.GetOwnedList(ItemType.all, OnGetOwnedList); After the processing of the GetOwnedList() method is completed, the OnGetOwnedList callback is triggered, which receives information about the specified purchased items and API call processing. We need to implement this callback method under the same class as in the following;
      void OnGetOwnedList(OwnedProductList _ownedProductList){ if(_ownedProductList.errorInfo != null){ if(_ownedProductList.errorInfo.errorCode == 0){// 0 means no error if(_ownedProductList.results != null){ foreach(OwnedProductVo item in _ownedProductList.results){ if(item.mConsumableYN == "Y"){ //consume the consumable items and OnConsume callback is triggered afterwards SamsungIAP.Instance.ConsumePurchasedItems(item.mPurchaseId, OnConsume); } if(item.mItemId == "BuySuperJump"){ superJump++; } else if(item.mItemId == "BuyUpgradedPlayer"){ playerMaterial = Resources.Load<Material>("playerMaterial"); MeshRenderer meshRenderer = GetComponent<MeshRenderer>(); meshRenderer.material = playerMaterial; } } } } } As you can see, some actions have been taken inside the game depending on the respective item IDs. For example, the super jump counter has been increased and the material of the player gets changed. If there is any consumable item which has not been reported as consumed, then the ConsumePurchasedItems() method is invoked. We describe this method in the next section.
      Consume purchased consumable items
      Use the ConsumePurchasedItems() method to report the purchased consumable item as consumed, which enables the item to be purchased again. See Acknowledge a purchased consumable item to understand this process better. When the process of the ConsumePurchasedItems() method in the previous section is finished, the item data and processing results are returned to the OnConsume callback method. We need to implement this method in the same way under the same class as we implemented the OnGetOwnedList method earlier.
      void OnConsume(ConsumedList _consumedList){ if(_consumedList.errorInfo != null){ if(_consumedList.errorInfo.errorCode == 0){ if(_consumedList.results != null){ foreach(ConsumeVo item in _consumedList.results){ if(item.mStatusCode == 0){ //successfully consumed and ready to be purchased again. } } } } } } Get purchasable IAP items
      The users may want to see details of the available IAP items in the store for the game. The GetProductsDetails() method helps to retrieve detailed information (for example, item name, price, or ID) about the IAP items registered in your game that are available for users to purchase. There is a UI button “Available Items” in our sample game for querying the purchasable items. After clicking this button, brief information for each item is presented in a simple dropdown list next to the button (see figure 3). To get the list of available items:
      Declare a button variable and a dropdown variable in the beginning of the “player.cs” script.
      public Button getProductsButton; public Dropdown itemList; Add a listener method for the “Available Items” button at the end of the Start() method.
      getProductsButton.onClick.AddListener(OnGetProductsButton); To initiate the GetProductsDetails() method, we need to implement the listener OnGetProductsButton() method.
      void OnGetProductsButton(){ //get all the product details SamsungIAP.Instance.GetProductsDetails("", OnGetProductsDetails); } After the processing is completed on the server side, the OnGetProductsDetails callback is triggered, which contains information about the available IAP items. Implement this callback method and add information of each item to the dropdown method so that the users can see them easily. In the example, we show only the item name and price.
      void OnGetProductsDetails(ProductInfoList _productList){ if (_productList.errorInfo != null){ if (_productList.errorInfo.errorCode == 0){// 0 means no error if (_productList.results != null){ itemList.ClearOptions(); List<string> optionItems = new List<string>(); int i = 1; foreach (ProductVo item in _productList.results){ string temp = i+ ". " + item.mItemName + ": $ " + item.mItemPrice; optionItems.Add(temp); i++; } itemList.AddOptions(optionItems); } } } }
      Figure 3: Showing the available IAP items in the game.

      The information about all IAP items is shown in the dropdown menu as a list. You can show only one specific item or more items by specifying their IDs in the GetProductsDetails() method if you want. Learn more about the method here.
      Purchase IAP items
      There are two UI buttons (see figures 1 and 3) in our sample game, namely “Buy Super Jump” and “Upgrade Player,” for purchasing consumable and non-consumable items, respectively. The variables for these two buttons are declared in the beginning of the Start() method and two listener methods: OnBuySuperJumpButton() and OnUpgradePlayerButton() are added at the end of the Start() method of “player.cs” script. Consequently, tapping on these buttons invokes the corresponding methods in the script. Follow the steps below to complete in-app purchasing:
      To enable the “Buy Super Jump” and the “Upgrade Player” buttons purchasing a super jump and a player upgrade, we need to instantiate the StartPayment() method inside the button listeners with the corresponding item IDs.void OnBuySuperJumpButton(){ //purchase a consumable item SamsungIAP.Instance.StartPayment("BuySuperJump", "", OnPayment); } void OnUpgradePlayerButton(){ //purchase a non-consumable item SamsungIAP.Instance.StartPayment("BuyUpgradedPlayer", "", OnPayment); } After the payment processing is completed, the OnPayment callback is triggered, which contains information about the purchased item, the transaction, and API call processing. We need to implement this callback method and act according to the item IDs as in the following:void OnPayment(PurchasedInfo _purchaseInfo){ if(_purchaseInfo.errorInfo != null){ if(_purchaseInfo.errorInfo.errorCode == 0){ if(_purchaseInfo.results != null){ //your purchase is successful if(_purchaseInfo.results.mConsumableYN == "Y"){ //consume the consumable items SamsungIAP.Instance.ConsumePurchasedItems(_purchaseInfo.results.mPurchaseId, OnConsume); } if(_purchaseInfo.results.mItemId == "BuySuperJump"){ superJump++; } else if(_purchaseInfo.results.mItemId == "BuyUpgradedPlayer"){ playerMaterial = Resources.Load<Material>("playerMaterial"); MeshRenderer meshRenderer = GetComponent<MeshRenderer>(); meshRenderer.material = playerMaterial; } } } } } For the ConsumePurchasedItems() method, we have already implemented the OnConsume listener method. In this way, in-app purchasing is fully implemented for both consumable and non-consumable items. Next, build the project, run it on your Galaxy device, and check that the IAP works flawlessly. In addition, you may update the APK of your game in Seller Portal and submit a beta version for more IAP testing. See the Test Guide to learn more about testing. Do not forget to switch the IAP operation mode to OPERATION_MODE_PRODUCTION before submitting the game to be published.
      Conclusion
      This tutorial explains the entire procedure of integrating the Samsung IAP Unity plugin and using the IAP functionalities for a sample game. Therefore, we hope that you can make use of this tutorial and develop an in-app purchase enabled game for Galaxy Store using Unity and sell your game items successfully to generate revenue.
      Follow Up
      This site has many resources for developers looking to build for and integrate with Samsung devices and services. Stay in touch with the latest news by creating a free account or by subscribing to our monthly newsletter. Visit the Marketing Resources page for information on promoting and distributing your apps. Finally, our developer forum is an excellent way to stay up-to-date on all things related to the Galaxy ecosystem.
      View the full blog at its source
    • By STF News
      The Galaxy Store is one of the top app stores to sell your Android games in many different countries. You can also sell various in-app purchase (IAP) items inside your games using the Samsung IAP SDK. As many of you now use the Unity engine to develop your games, Samsung has introduced a Unity plugin for the Samsung IAP SDK that enables you to implement IAP features. Follow the steps outlined in this blog to easily implement the Unity plugin into your project and utilize the Samsung IAP functionalities.
      Prerequisites
      It is assumed you are already familiar with the Samsung IAP procedure. If not, please read the IAP Helper programming guide carefully before proceeding further. After that, download the Samsung IAP Unity plugin package and go through its documentation. To avoid compatibility issues, make sure you meet the system requirements.
      There are three types of IAP items:
      Consumable: can be used only one time and re-purchasable Non-consumable: can be used any number of times and not re-purchasable Subscription: can be used any number of times while it is active For this example, we have developed a basic coin collecting game in Unity for Android and added UI buttons that allow users to buy IAP items (consumable and non-consumable), and a subscription. The “Buy Super Jump” button initiates purchasing a super jump item from the Galaxy Store using the Samsung IAP SDK. Super jump is a consumable item which enables the player to jump higher than normal. Similarly, the “Upgrade Player” button initiates purchasing a player upgrade, which is a non-consumable item. This blog only covers consumable and non-consumable purchases, we’ll discuss subscriptions in a future blog.

      Figure 1: Preview of the sample game developed in Unity.

      Note: You are required to develop your game/application in Unity beforehand to integrate the IAP Unity plugin into it.
      Integrate the Samsung IAP Unity plugin
      After creating the game in Unity, you need to enable Samsung IAP functionalities in your project. Follow the steps below:
      Import the Samsung IAP Unity plugin package into the project. In Unity, click Assets -> Import Package -> Custom Package and select the downloaded plugin package. You can now see the Plugins folder under your Assets folder and the “SamsungIAP.cs” script at Assets/Plugins/Script. Copy or move the “SamsungIAP.cs” script into the default scripts folder (where all the scripts are kept together) of your project so that other scripts can access it easily. If you don’t already have a scripts folder, create a new one and keep all your project scripts together along with “SamsungIAP.cs”. Create an empty game object in the Hierarchy tab and drag-and-drop the “SamsungIAP.cs” script onto it. In our sample project, we have renamed the game object as “SamsungIAP”. Click on the “SamsungIAP” game object and check whether the IAP functionality is enabled in the Inspector, as shown below:
      Figure 2: Samsung IAP is enabled for the project.

      Set the IAP operation mode
      IAP supports three operational modes. The production mode is for enabling billing for item purchases and the other two are for testing IAP functions without billing the game users for item purchases. The default operation mode is set to OPERATION_MODE_TEST with the return value as Success, but you can set the return value to Failure instead, or switch to OPERATION_MODE_PRODUCTION by checking (√) the Production Build checkbox in the Inspector as shown in figure 2. You can learn more about the IAP operation modes and how they work from here.
      Register the game and IAP items in the Seller Portal
      To process/test the Samsung IAP operations, both your game and any IAP items need to be registered in the Seller Portal. Follow the steps below:
      Ensure you have switched the platform of your game to Android and the package name is different from the apps registered in other app stores. You can rename the package name of your project from Player Settings -> Other Settings. Save your Unity project and build the APK file. In Unity, go to File -> Build Settings and then click the Build button. Follow the steps listed in Register an app and in-app items in Seller Portal and complete the registration of your game and IAP items accordingly. For our sample game, we have registered a consumable and a non-consumable item with the IDs “BuySuperJump” and “BuyUpgradedPlayer” respectively. Keep the item IDs in mind as they will be required when initiating the purchases. You can add testers (non-licensed and licensed) in the Binary tab of the Seller Portal while registering your game in the manner covered in the previous step. Licensed testers are not be charged for purchasing any IAP items. You can register the licensed testers in your Seller Portal profile. See IAP Testing for more information. Get previously purchased items
      Make sure to retrieve any previously purchased non-consumable and unconsumed items every time the user starts the game. Use the GetOwnedList() method of the IAP plugin to get information about the items the user has already purchased. However, please note there is a script “player.cs” in our project which is added to the main player game object as a component. From now on we will be editing the codes into this “player.cs” script to enable all the Samsung IAP functions for this project. Follow the steps below:
      Add the following line at the beginning to access the Samsung IAP libraries in this script.using Samsung; Call the GetOwnedList() method whenever the game launches, by adding the following line at the beginning of the Start() method. Learn more about the GetOwnedList() method here. After the processing of the GetOwnedList() method is completed, the OnGetOwnedList callback is triggered, which receives information about the specified purchased items and API call processing. We need to implement this callback method under the same class as in the following;void OnGetOwnedList(OwnedProductList _ownedProductList){ if(_ownedProductList.errorInfo != null){ if(_ownedProductList.errorInfo.errorCode == 0){// 0 means no error if(_ownedProductList.results != null){ foreach(OwnedProductVo item in _ownedProductList.results){ if(item.mConsumableYN == "Y"){ //consume the consumable items and OnConsume callback is triggered afterwards SamsungIAP.Instance.ConsumePurchasedItems(item.mPurchaseId, OnConsume); } if(item.mItemId == "BuySuperJump"){ superJump++; } else if(item.mItemId == "BuyUpgradedPlayer"){ playerMaterial = Resources.Load<Material>("playerMaterial"); MeshRenderer meshRenderer = GetComponent<MeshRenderer>(); meshRenderer.material = playerMaterial; } } } } } } As you can see, some actions have been taken inside the game depending on the respective item IDs. For example, the super jump counter has been increased and the material of the player gets changed. If there is any consumable item which has not been reported as consumed, then the ConsumePurchasedItems() method is invoked. We describe this method in the next section.
      Consume purchased consumable items
      Use the ConsumePurchasedItems() method to report the purchased consumable item as consumed, which enables the item to be purchased again. See Acknowledge a purchased consumable item to understand this process better. When the process of the ConsumePurchasedItems() method in the previous section is finished, the item data and processing results are returned to the OnConsume callback method. We need to implement this method in the same way under the same class as we implemented the OnGetOwnedList method earlier.
      void OnConsume(ConsumedList _consumedList){ if(_consumedList.errorInfo != null){ if(_consumedList.errorInfo.errorCode == 0){ if(_consumedList.results != null){ foreach(ConsumeVo item in _consumedList.results){ if(item.mStatusCode == 0){ //successfully consumed and ready to be purchased again. } } } } } } Get purchasable IAP items
      The users may want to see details of the available IAP items in the store for the game. The GetProductsDetails() method helps to retrieve detailed information (for example, item name, price, ID, etc.) about the IAP items registered in your game that are available for users to purchase. There is a UI button “Available Items” in our sample game for querying the purchasable items. After clicking this button, brief information for each item is presented in a simple dropdown list next to the button (see figure 3). To get the list of available items:
      Declare a button variable and a dropdown variable in the beginning of the “player.cs” script.public Button getProductsButton; public Dropdown itemList; Add a listener method for the “Available Items” button at the end of the Start() method.getProductsButton.onClick.AddListener(OnGetProductsButton); To initiate the GetProductsDetails() method, we need to implement the listener OnGetProductsButton() method.void OnGetProductsButton(){ //get all the product details SamsungIAP.Instance.GetProductsDetails("", OnGetProductsDetails); } After the processing is completed on the server side, the OnGetProductsDetails callback is triggered, which contains information about the available IAP items. Implement this callback method and add information of each item to the dropdown method so that the users can see them easily. In the example, we show only the item name and price.void OnGetProductsDetails(ProductInfoList _productList){ if (_productList.errorInfo != null){ if (_productList.errorInfo.errorCode == 0){// 0 means no error if (_productList.results != null){ itemList.ClearOptions(); List<string> optionItems = new List<string>(); int i = 1; foreach (ProductVo item in _productList.results){ string temp = i+ ". " + item.mItemName + ": $ " + item.mItemPrice; optionItems.Add(temp); i++; } itemList.AddOptions(optionItems); } } } }
      Figure 3: Showing the available IAP items in the game.

      The information of all IAP items is shown in the dropdown menu as a list. You can show only one specific item or more items by specifying their IDs in the GetProductsDetails() method if you want. Learn more about the method here.
      View the full blog at its source
    • By STF News
      Beta testing an app allows you to find and fix issues before publishing in Galaxy Store and provides a better user experience by incorporating feedback from your testers.
      The Galaxy Store Seller Portal team is excited to announce enhancements to beta testing. We’ve listened to you and have implemented your comments and suggestions to improve beta testing functionality!
      Beta test any app at any time
      If your app is already published in Galaxy Store, you can now beta test your app while it is being registered or under review. This allows you to test your app or updates to your app at any time.
      When updating a binary, you must use the same package name and make sure the beta version number is higher than the version number of your existing app. If the beta version number is the same or lower than the version number of your existing app and your beta tester has your existing app installed on their device, this beta tester cannot install the beta version. Likewise, when you publish your updated app (the version that will be published in Galaxy Store after your beta testing is completed), make sure this version number is higher than the beta version number. Otherwise, your beta testers are not able to update their beta version to the updated app. That is, when you assign a version number to your beta app and your updated app, the beta version number must be greater than the existing app's version number and the updated app's version number must be greater than the beta version number:
      (existing app version number) < (beta version number) < (updated app version number).
      Run open and closed beta tests simultaneously
      An open beta test allows anyone to download your app using the specified link. A closed beta test allows only the testers you specify (identified by their Samsung account) to download your app using the specified link. Previously, only one type of test could be run at a time. Now, you can run both an open and a closed beta test at the same time.
      Add a beta test app
      To test an app, add a beta test instance in Seller Portal.
      In Seller Portal, select the app for which you want to run a beta test. Complete the required information in the App Information and Binary tabs and click Add Beta Test.

      Select the type of beta test to run, click Add, and confirm that you want to add a beta test app.

      Your beta test app is added to the list of apps and the Application Title displays the type of beta test app being registered. Note the status of the beta test app is Beta Registering. Click on the status of the beta test app to open it in Seller Portal.

      Update any of the information for the beta test app in the tabbed areas (for example, add the binary to be tested). For a closed beta test, you must add Tester Settings (the Samsung account IDs of your testers) and Feedback Channel (an address where you receive feedback), located in the Binary tab. Note that the beta testing URL (the link you share with your testers) is located in the Binary tab.
      After you have entered the required information, click Submit Beta Test (if required information is missing, the button is grey).

      In the list of apps, when the beta test app status shows Beta Deployed, your app is ready to be tested!

      What’s next?
      These are just a couple of new features we’ve implemented based on suggestions we received and more updates are planned. Look for additional announcements about enhancements to beta testing in the near future.
      Refer to the App Registration Beta Test Guide in Seller Portal for more information about beta testing.
      Additional resources on the Samsung Developers site
      This site has many resources for developers looking to build for and integrate with Samsung devices and services. Stay in touch with the latest news by creating a free account or by subscribing to our monthly newsletter. Visit the Marketing Resources page for information on promoting and distributing your apps. Finally, our developer forum is an excellent way to stay up-to-date on all things related to the Galaxy ecosystem.
      View the full blog at its source
    • By STF News
      Galaxy AR Emoji SDK for Unity makes it possible to control the user’s AR Emoji avatar in a Unity application developed for Galaxy devices. You can add any custom animation movements to the user’s AR Emoji avatar in your Unity applications using the SDK (for example, a game application for Galaxy devices in which a user can select their own AR Emoji avatar as a player instead of the default game player). In this tutorial, you will learn how to add any custom animation to the AR Emoji avatar in a game or any other application using the Galaxy AR Emoji SDK for Unity.
      Prerequisites
      First, get your Samsung partnership approval from the Partnership Request Process to use the Galaxy AR Emoji SDK for Unity if you are not already a partner. The SDK team will approve the partnership through an immediate review as soon as they receive your partnership request. After getting your partnership approved, go through the basic tutorial by signing in to your account on the Galaxy AR Emoji Developer site.
      In order to animate the AR Emoji model, you need to load the model into your application (described in the “Importing the AR Emoji Model” section in the basic tutorial mentioned above). As our project name is “Animation Tutorial,” we recommend keeping the same name for your project. Besides, you can also add a feature to your app using an Android intent so that a user can create a new avatar by opening the AR Emoji camera directly from your app for a better user experience. Now, you are ready to proceed with this tutorial to animate the loaded model on Galaxy devices.
      Animate the AR emoji
      To animate the avatar, you need the following two components,
      Animation clip: the animation data containing information about animation movement. Animator controller: allows you to arrange a set of animation clips and associated animation transitions for a character or object. Get familiar with how these two components work together to incorporate animation into the AR Emoji model. For this tutorial, you should understand these components in order to follow the successive sections to complete the project.
      Create animation clips
      Our project facilitates four different types of animation for the loaded model, so we need four animation clips. The AR Emoji supports only the ANIM format clips (see how to create animation clips for the AR Emoji using the “AnimationGenTool.unitypackage” package of the SDK).
      For this project, we use the animation clips included in the SDK (see Assets → Resources → Animations → Mecanim). But you can use any custom clips created by using tools such as 3Ds Max, AutoCAD Maya, or tools downloaded from other sources, like Mixamo.

      Figure 1: The animation clips included in the SDK.

      One more thing you need to make sure is that every animation clip has the Loop Time option selected so that the AR Emoji doesn’t stop animating after a single animation movement. To do this, select the animation clip and check the Loop Time in the Inspector. Do not forget to do the same for all the animation clips.

      Figure 2: Enabling the Loop Time for Hip Hop Dancing animation clip.

      Our animation clips are now ready. In the next section, we will configure our animator controller for utilizing these clips.
      Configure the animator controller
      Although you can create your animator controller, the default “AnimController” is available under Assets → Resources.

      Figure 3: The default animator controller for the loaded AR Emoji.

      You need to connect the controller to the loaded model. Follow the steps below:
      Open the “GettingAREmojiSample” scene, select the “GLTFComponent” in the hierarchy, and then make sure to check the Use Legacy Animator in the Inspector.
      Add the animation clips and set appropriate transition conditions between them. Double-Click on “AnimController” to open the Animator tab, which shows the state machine of the controller.

      Figure 4: The state machine of the animator controller.

      Drag all the animation clips to the state machine and place them in a convenient position. Note that “Idle” is the default animation state for our model.

      Figure 5: Drag the animation clips into the state machine.

      It's time to make the transitions between the states and set appropriate conditions. To do so, you need to create one Boolean parameter for each state. Click the + button and then Bool in the Parameters tab as shown in the diagram below, and name them according to their states (for example, walk, jump, yelling, and dance).

      Figure 6: Create a Boolean parameter for each state (animation clip).

      Right-click on the “Idle” state, select Make Transition, and click on any other state (for example, “Hip Hop Dancing”). As a result, a transition arrow from “Idle” to the selected state is generated. Select the arrow as shown below and then perform the following tasks in the Inspector:

      Figure 7: Select the transition arrow.

      Uncheck the Has Exit Time option for the transition.

      Figure 8: Disable the Has Exit Time option.

      Add a condition for the transition by clicking on the + button.

      Figure 9: Add a condition for the transition.

      Select the appropriate parameter (for example, “dance” for the “Hip Hop Dancing” state).

      Figure 10: Select the parameter for the condition.

      Set the value according to the transition condition (in this example, true, which indicates the model will go from the “Idle” to “Hip Hop Dancing” state).

      Figure 11: Select the condition value for the transition.

      We have completed the transition condition for the “Idle“ to “Hip Hop Dancing” state. For the reverse transition, “Hip Hop Dancing“ to “Idle,” everything is the same as above, except the parameter value. The value should be false as the avatar will go back from the “Hip Hop Dancing” state to the “Idle” state. This completes the full transition condition for the “Hip Hop Dancing” state.
      Complete the transition conditions in the same way for the rest of the states (Jump, Walk, and Yelling). The final state machine should look like the following image:

      Figure 12: The complete state machine for our project.

      Modify the application UI
      So far, we have created our animation clips and the animator controller. Now, we need to modify the application UI for the users to interact with the application. As a result, they can animate their avatars by simply tapping a button. We need to add four buttons to the canvas of the “GettingAREmojiSample” scene, which enables the different animations for our model. Follow the steps below:
      Open the “GettingAREmojiSample” scene, add a button to the panel of the canvas (see the screenshot below), rename it as you wish (for example, “jump_button”), and set the width to 200 and the height to 60 in the Inspector.

      Figure 13: Create a button in UI and configure the property in the Inspector.

      Duplicate the button three times to make a total of four buttons, rename and position them conveniently (as shown below), and change the button texts to indicate the appropriate animation actions.

      Figure 14: Add four buttons in the UI and name them according to their actions.

      The UI is now ready along with the animator controller.
      Modify the script
      The final task is to modify the script so that tapping on a button changes the value of the corresponding Boolean parameter within the controller. At this stage, if we can somehow change the value of the Boolean parameter at run-time, the model will be animated accordingly. To change the value by interacting with the buttons, we need to edit the “ButtonBehaviour.cs” script which is attached to the canvas of the “GettingAREmojiSample” scene. Perform the following steps:
      Open the “ButtonBehaviour.cs” script from the Assets → Scripts in any editor (such as Visual Studio).
      Declare the variables for the four buttons at the beginning of the ButtonBehaviour class, as shown below:
      public Button jumpBtn; public Button yellBtn; public Button walkBtn; public Button danceBtn; Add references to these variables from the UI buttons. Go back to Unity and select the canvas in the Hierarchy. In the Inspector, the references are empty for the button variables. Drag each of the buttons from the panel in the Hierarchy to their corresponding empty fields in the Inspector.

      Figure 15: Add button references to button variables.

      Add listeners to the button variables at the end of the Start() method, as shown below:
      walkBtn.onClick.AddListener(OnClickWalk); yellBtn.onClick.AddListener(OnClickYell); jumpBtn.onClick.AddListener(OnClickJump); danceBtn.onClick.AddListener(OnClickDance); Declare four methods/functions for each listener, immediately below the Start() method:
      private void OnClickDance(){ } private void OnClickJump(){ } private void OnClickYell(){ } private void OnClickWalk(){ } When a user taps on a button in our application, the corresponding method is invoked at run-time. Therefore, we have to write some code inside each function to change the value of the corresponding Boolean parameter.
      To access the Boolean parameters within the animator controller, we need to declare an animator variable in the script. Write a line of code to declare the variable at the beginning of the class and add the Update() method inside the class.
      public Animator anim; void Update(){ if (anim == null){ GameObject o = GameObject.Find("rig_GRP"); if (o != null){ anim = o.GetComponent<Animator>(); } } } Finally, when a specific button is tapped by a user, the corresponding Boolean value should be set as true and others as false in the invoked function. See below for an example for one method and complete the others in the same way.
      private void OnClickDance(){ anim.SetBool("walk", false); anim.SetBool("yelling", false); anim.SetBool("jump", false); anim.SetBool("dance", true); } Now, save the project and click the Build and Run. It installs and launches the application in your Galaxy device which should be connected to your PC through a USB cable. After loading the AR Emoji, you can animate it by tapping any of the animation buttons. See the screenshots below from our demo project.

      Figure 16: The avatar is being animated.

      Conclusion
      Hopefully, you have enjoyed this tutorial and learned about AR Emoji using the AR Emoji SDK for Unity. You can use this knowledge to develop more entertaining applications that incorporate the AR Emoji avatars with other custom animation clips. You can also develop Android games using your own AR Emoji with this animation technique.
      View the full blog at its source


×
×
  • Create New...