Esempio n. 1
0
        /// <summary>
        /// Converts to UnityIAP AppStore.
        /// </summary>
        /// <returns>The app store.</returns>
        /// <param name="store">Store.</param>
        public static AppStore GetAppStore(IAPAndroidStore store)
        {
            switch (store)
            {
            case IAPAndroidStore.AmazonAppStore:
                return(AppStore.AmazonAppStore);

            case IAPAndroidStore.GooglePlay:
                return(AppStore.GooglePlay);

            case IAPAndroidStore.CloudMoolah:
                return(AppStore.CloudMoolah);

            case IAPAndroidStore.SamsungApps:
                return(AppStore.SamsungApps);

            case IAPAndroidStore.XiaomiMiPay:
                return(AppStore.XiaomiMiPay);

            case IAPAndroidStore.NotSpecified:
                return(AppStore.NotSpecified);

            default:
                return(AppStore.NotSpecified);
            }
        }
Esempio n. 2
0
 void SetTargetAndroidStore(IAPAndroidStore store)
 {
     UnityEngine.Purchasing.AppStore androidStore = InAppPurchasing.GetAppStore(store);
     UnityEditor.Purchasing.UnityPurchasingEditor.TargetAndroidStore(androidStore);
 }
Esempio n. 3
0
        void IAPModuleGUI()
        {
            DrawModuleHeader();

            // Now draw the GUI.
            if (!isIAPModuleEnable.boolValue)
            {
                return;
            }

#if !EM_UIAP
            EditorGUILayout.Space();
            EditorGUILayout.BeginVertical(EM_GUIStyleManager.UppercaseSectionBox);
            EditorGUILayout.HelpBox(UnityIAPEnableInstruction, MessageType.Error, true);
            EditorGUILayout.EndVertical();
#else
            EditorGUILayout.Space();
            DrawUppercaseSection("IAP_AUTO_INIT_CONFIG", "AUTO INITIALIZATION", () =>
            {
                EditorGUILayout.PropertyField(IAPProperties.autoInit.property, IAPProperties.autoInit.content);
                if (!IAPProperties.autoInit.property.boolValue)
                {
                    EditorGUILayout.HelpBox(IAPManualInitInstruction, MessageType.Info);
                }
            });

            // Select target Android store, like using the Window > Unity IAP > Android > Target ... menu item.
            EditorGUILayout.Space();
            DrawUppercaseSection("ANDROID_TARGET_STORE_FOLDOUT_KEY", "TARGET ANDROID STORE", () =>
            {
                EditorGUI.BeginChangeCheck();
                IAPProperties.targetAndroidStore.property.enumValueIndex = EditorGUILayout.Popup(
                    IAPProperties.targetAndroidStore.content.text,
                    IAPProperties.targetAndroidStore.property.enumValueIndex,
                    IAPProperties.targetAndroidStore.property.enumDisplayNames
                    );
                if (EditorGUI.EndChangeCheck())
                {
                    SetTargetAndroidStore((IAPAndroidStore)IAPProperties.targetAndroidStore.property.enumValueIndex);
                }

                // Enable Amazon sandbox testing.
                androidStore = (IAPAndroidStore)IAPProperties.targetAndroidStore.property.enumValueIndex;
                if (androidStore == IAPAndroidStore.AmazonAppStore)
                {
                    EditorGUILayout.PropertyField(IAPProperties.enableAmazoneSandboxTesting.property, IAPProperties.enableAmazoneSandboxTesting.content);
                }
            });

            // Apple's Ask To Buy settings.
            EditorGUILayout.Space();
            DrawUppercaseSection("APPLE_ASK_TO_BUY_FOLDOUT_KEY", "APPLE ASK-TO-BUY", () =>
            {
                // Apple Ask To Buy simulation in sandbox.
                EditorGUILayout.PropertyField(IAPProperties.simulateAppleAskToBuy.property, IAPProperties.simulateAppleAskToBuy.content);
            });

            // Apple's promotional purchases settings.
            EditorGUILayout.Space();
            DrawUppercaseSection("APPLE_PROMOTIONAL_PURCHASES_FOLDOUT_KEY", "APPLE PROMOTIONAL PURCHASES", () =>
            {
                // Whether to intercept Apple's promotional purchases.
                EditorGUILayout.PropertyField(IAPProperties.interceptApplePromotionalPurchases.property, IAPProperties.interceptApplePromotionalPurchases.content);
            });

            // Receipt validation
            EditorGUILayout.Space();
            DrawUppercaseSection("RECEIPT_VALIDATION_FOLDOUT_KEY", "RECEIPT VALIDATION", () =>
            {
                EditorGUILayout.HelpBox("Unity IAP offers local receipt validation for extra security. Apple stores and Google Play store only.", MessageType.None);

                // iOS store.
                EditorGUI.BeginDisabledGroup(!isAppleTangleValid);
                IAPProperties.validateAppleReceipt.property.boolValue = EditorGUILayout.Toggle(IAPProperties.validateAppleReceipt.content, IAPProperties.validateAppleReceipt.property.boolValue);
                EditorGUI.EndDisabledGroup();

                // Always disable the option if AppleTangle is not valid.
                if (!isAppleTangleValid)
                {
                    IAPProperties.validateAppleReceipt.property.boolValue = false;
                }

                // Google Play store.
                bool isTargetingGooglePlay = androidStore == IAPAndroidStore.GooglePlay;
                EditorGUI.BeginDisabledGroup(!isGooglePlayTangleValid);
                IAPProperties.validateGooglePlayReceipt.property.boolValue = EditorGUILayout.Toggle(IAPProperties.validateGooglePlayReceipt.content, IAPProperties.validateGooglePlayReceipt.property.boolValue);
                EditorGUI.EndDisabledGroup();

                // Always disable the option if GooglePlayTangle is not valid.
                if (!isGooglePlayTangleValid)
                {
                    IAPProperties.validateGooglePlayReceipt.property.boolValue = false;
                }

                if (!isAppleTangleValid || (!isGooglePlayTangleValid && isTargetingGooglePlay))
                {
                    string rvMsg = "Please go to Window > Unity IAP > IAP Receipt Validation Obfuscator and create obfuscated secrets to enable receipt validation for Apple stores and Google Play store.";

                    if (!isAppleTangleValid)
                    {
                        rvMsg += " Note that you don't need to provide a Google Play public key if you're only targeting Apple stores.";
                    }
                    else
                    {
                        rvMsg = rvMsg.Replace("Apple stores and ", "");
                    }

                    if (isGooglePlayTangleValid || !isTargetingGooglePlay)
                    {
                        rvMsg = rvMsg.Replace(" and Google Play store", "");
                    }

                    EditorGUILayout.HelpBox(rvMsg, MessageType.Warning);
                }
            });

            // Product list
            EditorGUILayout.Space();
            DrawUppercaseSection("PRODUCTS_FOLDOUT_KEY", "PRODUCTS", () =>
            {
                EMProperty products = IAPProperties.products;

                if (products.property.arraySize > 0)
                {
                    EditorGUI.indentLevel++;
                    isIAPProductsFoldout = EditorGUILayout.Foldout(isIAPProductsFoldout, products.property.arraySize + " " + products.content.text, true);
                    EditorGUI.indentLevel--;

                    if (isIAPProductsFoldout)
                    {
                        // Draw the array of IAP products.
                        DrawArrayProperty(products.property, DrawIAPProduct);

                        // Detect duplicate product names.
                        string duplicateName = EM_EditorUtil.FindDuplicateFieldInArrayProperty(products.property, IAPProduct_NameProperty);
                        if (!string.IsNullOrEmpty(duplicateName))
                        {
                            EditorGUILayout.Space();
                            EditorGUILayout.HelpBox("Found duplicate name of \"" + duplicateName + "\".", MessageType.Warning);
                        }
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("No products added.", MessageType.None);
                }

                if (GUILayout.Button("Add New Product", GUILayout.Height(EM_GUIStyleManager.buttonHeight)))
                {
                    // Add new IAP product.
                    AddNewProduct(products.property);

                    // Open the foldout if it's closed.
                    isIAPProductsFoldout = true;
                }
            });

            // Constant generation.
            EditorGUILayout.Space();
            DrawUppercaseSection("IAP_CONTANTS_GENERATION_FOLDOUT_KEY", "CONSTANTS GENERATION", () =>
            {
                EditorGUILayout.HelpBox(IAPConstantGenerationIntro, MessageType.None);
                if (GUILayout.Button("Generate Constants Class", GUILayout.Height(EM_GUIStyleManager.buttonHeight)))
                {
                    GenerateIAPConstants();
                }
            });
#endif
        }
Esempio n. 4
0
 void SetTargetAndroidStore(IAPAndroidStore store)
 {
     UnityEngine.Purchasing.AndroidStore androidStore = IAPManager.GetAndroidStore(store);
     UnityEngine.Purchasing.UnityPurchasingEditor.TargetAndroidStore(androidStore);
 }