Exemple #1
0
        // Open the dialog to allow the user to purchase the asset
        static public AssetStoreInstaBuyWindow ShowAssetStoreInstaBuyWindow(AssetStoreAsset asset, string purchaseMessage, string paymentMethodCard, string paymentMethodExpire, string priceText)
        {
            AssetStoreInstaBuyWindow w = EditorWindow.GetWindowWithRect <AssetStoreInstaBuyWindow>(new Rect(100, 100, 400, kStandardHeight), true, "Buy package from Asset Store");

            if (w.m_Purchasing != PurchaseStatus.Init)
            {
                EditorUtility.DisplayDialog("Download in progress", "There is already a package download in progress. You can only have one download running at a time", "Close");
                return(w);
            }

            w.position = new Rect(100, 100, 400, kStandardHeight);
            w.m_Parent.window.m_DontSaveToLayout = true;
            w.m_Asset      = asset;
            w.m_Password   = "";
            w.m_Message    = "";
            w.m_Purchasing = PurchaseStatus.Init;
            w.m_NextAllowedBuildRequestTime = 0.0;
            w.m_BuildAttempts = 0;

            w.m_PurchaseMessage     = purchaseMessage;
            w.m_PaymentMethodCard   = paymentMethodCard;
            w.m_PaymentMethodExpire = paymentMethodExpire;
            w.m_PriceText           = priceText;
            UsabilityAnalytics.Track(string.Format("/AssetStore/ShowInstaBuy/{0}/{1}", w.m_Asset.packageID, w.m_Asset.id));
            return(w);
        }
Exemple #2
0
 private void ImportPackage(AssetStoreAsset asset)
 {
     if (AssetStoreAssetInspector.paymentAvailability == AssetStoreAssetInspector.PaymentAvailability.AnonymousUser)
     {
         this.LoginAndImport(asset);
     }
     else
     {
         AssetStoreInstaBuyWindow.ShowAssetStoreInstaBuyWindowBuilding(asset);
     }
 }
 void ImportPackage(AssetStoreAsset asset)
 {
     if (paymentAvailability == PaymentAvailability.AnonymousUser)
     {
         LoginAndImport(asset);
     }
     else
     {
         AssetStoreInstaBuyWindow.ShowAssetStoreInstaBuyWindowBuilding(asset);
     }
 }
        private void InitiateBuySelected(bool firstAttempt)
        {
            AssetStoreAsset firstAsset = AssetStoreAssetSelection.GetFirstAsset();

            if (firstAsset == null)
            {
                EditorUtility.DisplayDialog("No asset selected", "Please select asset before buying a package", "ok");
            }
            else if (AssetStoreAssetInspector.paymentAvailability == AssetStoreAssetInspector.PaymentAvailability.AnonymousUser)
            {
                if (AssetStoreClient.LoggedIn())
                {
                    AssetStoreAssetSelection.RefreshFromServer(delegate
                    {
                        this.InitiateBuySelected(false);
                    });
                }
                else if (firstAttempt)
                {
                    this.LoginAndInitiateBuySelected();
                }
            }
            else if (AssetStoreAssetInspector.paymentAvailability == AssetStoreAssetInspector.PaymentAvailability.ServiceDisabled)
            {
                if (firstAsset.previewInfo == null)
                {
                    return;
                }
                AssetStore.Open(string.Format("content/{0}/directpurchase", firstAsset.packageID));
            }
            else if (AssetStoreAssetInspector.paymentAvailability == AssetStoreAssetInspector.PaymentAvailability.BasketNotEmpty)
            {
                if (firstAsset.previewInfo == null)
                {
                    return;
                }
                if (firstAttempt)
                {
                    AssetStoreAssetSelection.RefreshFromServer(delegate
                    {
                        this.InitiateBuySelected(false);
                    });
                }
                else
                {
                    AssetStore.Open(string.Format("content/{0}/basketpurchase", firstAsset.packageID));
                }
            }
            else
            {
                AssetStoreInstaBuyWindow.ShowAssetStoreInstaBuyWindow(firstAsset, AssetStoreAssetInspector.s_PurchaseMessage, AssetStoreAssetInspector.s_PaymentMethodCard, AssetStoreAssetInspector.s_PaymentMethodExpire, AssetStoreAssetInspector.s_PriceText);
            }
        }
Exemple #5
0
 private void LoginAndImport(AssetStoreAsset asset)
 {
     AssetStoreLoginWindow.Login("Please login to the Asset Store in order to get download information for the package.", delegate(string errorMessage)
     {
         if (errorMessage == null)
         {
             AssetStoreAssetSelection.RefreshFromServer(delegate
             {
                 AssetStoreInstaBuyWindow.ShowAssetStoreInstaBuyWindowBuilding(asset);
             });
         }
     });
 }
        // For free or already purchased packages this will open the dialog
        // and just import the package.
        static public void ShowAssetStoreInstaBuyWindowBuilding(AssetStoreAsset asset)
        {
            AssetStoreInstaBuyWindow w = ShowAssetStoreInstaBuyWindow(asset, "", "", "", "");

            if (w.m_Purchasing != PurchaseStatus.Init)
            {
                EditorUtility.DisplayDialog("Download in progress", "There is already a package download in progress. You can only have one download running at a time", "Close");
                return;
            }
            w.m_Purchasing    = PurchaseStatus.StartBuild;
            w.m_BuildAttempts = 1;
            asset.previewInfo.buildProgress = 0f;
        }
Exemple #7
0
        public static void ShowAssetStoreInstaBuyWindowBuilding(AssetStoreAsset asset)
        {
            AssetStoreInstaBuyWindow assetStoreInstaBuyWindow = AssetStoreInstaBuyWindow.ShowAssetStoreInstaBuyWindow(asset, string.Empty, string.Empty, string.Empty, string.Empty);

            if (assetStoreInstaBuyWindow.m_Purchasing != AssetStoreInstaBuyWindow.PurchaseStatus.Init)
            {
                EditorUtility.DisplayDialog("Download in progress", "There is already a package download in progress. You can only have one download running at a time", "Close");
                return;
            }
            assetStoreInstaBuyWindow.m_Purchasing    = AssetStoreInstaBuyWindow.PurchaseStatus.StartBuild;
            assetStoreInstaBuyWindow.m_BuildAttempts = 1;
            asset.previewInfo.buildProgress          = 0f;
            Analytics.Track(string.Format("/AssetStore/ShowInstaFree/{0}/{1}", assetStoreInstaBuyWindow.m_Asset.packageID, assetStoreInstaBuyWindow.m_Asset.id));
        }
Exemple #8
0
        public void OnGUI()
        {
            AssetStoreInstaBuyWindow.LoadLogos();
            if (this.m_Asset == null)
            {
                return;
            }
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.Space(10f);
            switch (this.m_Purchasing)
            {
            case AssetStoreInstaBuyWindow.PurchaseStatus.Init:
                this.PasswordGUI();
                break;

            case AssetStoreInstaBuyWindow.PurchaseStatus.InProgress:
                if (this.m_Purchasing == AssetStoreInstaBuyWindow.PurchaseStatus.InProgress)
                {
                    GUI.enabled = false;
                }
                this.PasswordGUI();
                break;

            case AssetStoreInstaBuyWindow.PurchaseStatus.Declined:
                this.PurchaseDeclinedGUI();
                break;

            case AssetStoreInstaBuyWindow.PurchaseStatus.Complete:
                this.PurchaseSuccessGUI();
                break;

            case AssetStoreInstaBuyWindow.PurchaseStatus.StartBuild:
            case AssetStoreInstaBuyWindow.PurchaseStatus.Building:
            case AssetStoreInstaBuyWindow.PurchaseStatus.Downloading:
                this.DownloadingGUI();
                break;
            }
            GUILayout.EndVertical();
        }
        /**
         * Initiate a purchase of the selected package from the asset store.
         * The package will be the one that contains the currently selected asset.
         *
         * Since not all users may have allowed for single click purchases this can result
         * in two scenarios:
         * 1. single click allowed and a native purchase acknowledgement dialog appears to
         *    finalize the purchase.
         * 2. single click is not allowed and the package is put to an asset store basket.
         *    Then the asset store window is displayed with the basket open.
         */
        void InitiateBuySelected(bool firstAttempt)
        {
            //Debug.Log("payavail " + paymentAvailability.ToString());
            // Ask the asset store if the use has allowed single click payments
            AssetStoreAsset asset = AssetStoreAssetSelection.GetFirstAsset();

            if (asset == null)
            {
                EditorUtility.DisplayDialog("No asset selected", "Please select asset before buying a package", "ok");
            }
            else if (paymentAvailability == PaymentAvailability.AnonymousUser)
            {
                // Maybe the asset store window did a login already and we have a session key
                // then we just need to fetch the new info
                if (AssetStoreClient.LoggedIn())
                {
                    AssetStoreAssetSelection.RefreshFromServer(delegate() {
                        InitiateBuySelected(false);
                    });
                }
                else if (firstAttempt)
                {
                    LoginAndInitiateBuySelected();
                }
            }
            else if (paymentAvailability == PaymentAvailability.ServiceDisabled)
            {
                // Use the asset store window to complete the purchase since single click is not possible
                if (asset.previewInfo == null)
                {
                    return;
                }
                AssetStore.Open(string.Format("content/{0}/directpurchase", asset.packageID));
            }
            else if (paymentAvailability == PaymentAvailability.BasketNotEmpty)
            {
                // Use the asset store window to complete the purchase since there is already \
                // something in the users basket
                if (asset.previewInfo == null)
                {
                    return;
                }

                // Maybe the basket has been emptied and this is a retry by the user
                if (firstAttempt)
                {
                    AssetStoreAssetSelection.RefreshFromServer(delegate() {
                        InitiateBuySelected(false);
                    });
                }
                else
                {
                    AssetStore.Open(string.Format("content/{0}/basketpurchase", asset.packageID));
                }
            }
            else
            {
                // Show single click window
                AssetStoreInstaBuyWindow.ShowAssetStoreInstaBuyWindow(asset,
                                                                      AssetStoreAssetInspector.s_PurchaseMessage,
                                                                      AssetStoreAssetInspector.s_PaymentMethodCard,
                                                                      AssetStoreAssetInspector.s_PaymentMethodExpire,
                                                                      AssetStoreAssetInspector.s_PriceText
                                                                      );
            }
        }