From 09d7d4fa35dc2c4f75d2464a92ecb363830ccf38 Mon Sep 17 00:00:00 2001 From: alihan98ersoy <39373386+alihan98ersoy@users.noreply.github.com> Date: Mon, 21 Aug 2023 10:40:13 +0300 Subject: [PATCH] Iap second demo scene (#429) * A bool input has been added to the PurchaseProduct method to prevent it from being consumed optionally. Thus, those who wish can make their own consumption. * isUserOwnThisProduct method was added to see if the user has a specific product. (You need to call after initSuccess) * isIapAvailable method added. * GetAllOwnedPurchasesasList method added. This method will return owned products. (You need to call after initSuccess) * GetProductsList method added. This method will return information on products as a list. (You need to call after initSuccess) **_Reminder:_** You can still use the GetProductInfo method for specific products. * OnObtainOwnedPurchasesSuccess & OnObtainOwnedPurchaseRecordSuccess callbacks fixed. _**Reminder:**_ When testing non-consumable products with a sandbox, if you consume the product, you will not see that you have the product. If you don't consume, you can also see ownedpurchases. Just consume the product before you test repurchase. This is only for sandbox testing, in a normal process, you should consume after purchase. * Second IAP demo scene has been created to show how to use IAP and Account kit in multiple scenes. --- .../Demos/IAP/Second Demo-Menu_Store.meta | 8 + .../Second Demo-Menu_Store/MainMenuManager.cs | 199 + .../MainMenuManager.cs.meta | 11 + .../Scene0_MainMenu.unity | 2109 ++++++ .../Scene0_MainMenu.unity.meta | 7 + .../Second Demo-Menu_Store/Scene1_Store.unity | 6210 +++++++++++++++++ .../Scene1_Store.unity.meta | 7 + .../Second Demo-Menu_Store/StoreManager.cs | 140 + .../StoreManager.cs.meta | 11 + Assets/Huawei/Scripts/IAP/HMSIAPManager.cs | 71 +- 10 files changed, 8757 insertions(+), 16 deletions(-) create mode 100644 Assets/Huawei/Demos/IAP/Second Demo-Menu_Store.meta create mode 100644 Assets/Huawei/Demos/IAP/Second Demo-Menu_Store/MainMenuManager.cs create mode 100644 Assets/Huawei/Demos/IAP/Second Demo-Menu_Store/MainMenuManager.cs.meta create mode 100644 Assets/Huawei/Demos/IAP/Second Demo-Menu_Store/Scene0_MainMenu.unity create mode 100644 Assets/Huawei/Demos/IAP/Second Demo-Menu_Store/Scene0_MainMenu.unity.meta create mode 100644 Assets/Huawei/Demos/IAP/Second Demo-Menu_Store/Scene1_Store.unity create mode 100644 Assets/Huawei/Demos/IAP/Second Demo-Menu_Store/Scene1_Store.unity.meta create mode 100644 Assets/Huawei/Demos/IAP/Second Demo-Menu_Store/StoreManager.cs create mode 100644 Assets/Huawei/Demos/IAP/Second Demo-Menu_Store/StoreManager.cs.meta diff --git a/Assets/Huawei/Demos/IAP/Second Demo-Menu_Store.meta b/Assets/Huawei/Demos/IAP/Second Demo-Menu_Store.meta new file mode 100644 index 00000000..c840cb0a --- /dev/null +++ b/Assets/Huawei/Demos/IAP/Second Demo-Menu_Store.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c9a74e9394a7a7c45af2f4534ba22b4d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Huawei/Demos/IAP/Second Demo-Menu_Store/MainMenuManager.cs b/Assets/Huawei/Demos/IAP/Second Demo-Menu_Store/MainMenuManager.cs new file mode 100644 index 00000000..1d9ad426 --- /dev/null +++ b/Assets/Huawei/Demos/IAP/Second Demo-Menu_Store/MainMenuManager.cs @@ -0,0 +1,199 @@ +using HmsPlugin; +using HuaweiMobileServices.IAP; +using HuaweiMobileServices.Id; +using HuaweiMobileServices.Utils; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.SceneManagement; +using UnityEngine.UI; + +/* This demo scene has been created to show how to use IAP and Account kit in multiple scenes. +* Here are the steps to use this demo. +* 1. Complete the quick start steps. https://evilminddevs.gitbook.io/hms-unity-plugin/getting-started/quick-start +* 2. Enable Account kit - IAP from kit settings. https://evilminddevs.gitbook.io/hms-unity-plugin/getting-started/quick-start/connect-your-game-with-the-hms-kit-managers +* 3. Make sure you enabled IAP and Account kit services in the AppGallery console. https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/config-agc-0000001050033072#section382112213818 +* 4. Add These products to your project. (with same productID) https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/config-product-0000001050033076 +* a. Product ID: coin100 - Type: consumable +* b. Product ID: coin1000 - Type: consumable +* c. Product ID: removeAds - Type: non-consumable +* d. Product ID: premium - Type: subscription (1 week) +* 5. Add these products to IAP tab. Unity > Huawei > Kit Settings > IAP. Then click create constant classes +* +* Have a question? You can ask by creating an issue in our project on Github or via our discord channel. +*/ + + +public class MainMenuManager : MonoBehaviour +{ + string TAG = "[MainMenuManager]:"; + + Button playBtn, storeBtn, signinBtn; + Text userTxt, coinTxt; + void Start() + { + Screen.orientation = ScreenOrientation.Landscape; + + playBtn = GameObject.Find("Play").GetComponent