Beispiel #1
0
    //--------------------------------------
    // AN_iSkuDetailsResponseListener
    //--------------------------------------

    public void OnSkuDetailsResponse(SA_Result billingResult, List <AN_SkuDetails> skuDetailsList)
    {
        AN_Logger.Log("OnSkuDetailsResponse IsSucceeded: " + billingResult.IsSucceeded);
        if (billingResult.IsSucceeded)
        {
            AN_Logger.Log("Loaded " + skuDetailsList.Count + " products");
            foreach (var skuDetails in skuDetailsList)
            {
                AN_Logger.Log("--------------------->");
                PrintSku(skuDetails);

                var productView = Instantiate(m_ProductView.gameObject, m_ProductView.transform.parent).GetComponent <AN_ProductView>();
                productView.transform.localScale = m_ProductView.transform.localScale;
                productView.gameObject.SetActive(true);
                productView.ProductTitle.text = skuDetails.Title;
                if (!string.IsNullOrEmpty(skuDetails.IconUrl))
                {
                    SA_CachedRequestsFactory.GetTexture2D(skuDetails.IconUrl, texture =>
                    {
                        productView.ProductImage.texture = texture;
                    });
                }

                var productPurchasedInfo = IsProductPurchased(skuDetails);

                if (productPurchasedInfo != null)
                {
                    productView.BuyButton.GetComponentInChildren <Text>().text = "Consume";
                    productView.BuyButton.onClick.AddListener(() =>
                    {
                        var paramsBuilder = AN_ConsumeParams.NewBuilder();
                        paramsBuilder.SetPurchaseToken(productPurchasedInfo.PurchaseToken);

                        m_BillingClientSample.Client.ConsumeAsync(paramsBuilder.Build(), this);
                    });
                }
                else
                {
                    productView.BuyButton.GetComponentInChildren <Text>().text = "Buy";
                    productView.BuyButton.onClick.AddListener(() =>
                    {
                        var paramsBuilder = AN_BillingFlowParams.NewBuilder();
                        paramsBuilder.SetSkuDetails(skuDetails);

                        m_BillingClientSample.Client.LaunchBillingFlow(paramsBuilder.Build());
                    });
                }
            }
        }
    }
Beispiel #2
0
 /// <summary>
 /// Download user profile image of a given size
 /// </summary>
 /// <param name="size">Requested profile image size</param>
 /// <param name="callback">Callback with user Texture2D profile image</param>
 public void GetProfileImage(SA_FB_ProfileImageSize size, Action <Texture2D> callback)
 {
     GetProfileURL(size, url => { SA_CachedRequestsFactory.GetTexture2D(url, callback); });
 }
Beispiel #3
0
 void TestMe()
 {
     SA_CachedRequestsFactory.GetTexture2D("https://lh6.googleusercontent.com/--WOsAL7DUtk/AAAAAAAAAAI/AAAAAAAAAD8/zT7QiKYB2A0/photo.jpg", (texture) => {
         m_userAvatar.texture = texture;
     });
 }