コード例 #1
0
ファイル: IapTest.cs プロジェクト: asmCode/pix_it_all_2
    private void RefreshPurchases()
    {
        foreach (Transform child in m_productsContainer)
        {
            GameObject.Destroy(child.gameObject);
        }


        if (!m_purchaser.IsInitialized())
        {
            return;
        }

        var products = m_purchaser.GetProducts();

        foreach (var product in products)
        {
            Button prod  = Instantiate(m_productPrefab, Vector3.zero, Quaternion.identity);
            var    label = prod.GetComponentInChildren <Text>();
            label.text = string.Format("id={0}, price={1}, owned={2}", product.Id, product.LocalizedPrice, product.Owned);
            prod.transform.SetParent(m_productsContainer.transform);
            prod.onClick.AddListener(() =>
            {
                m_purchaser.BuyProductId(product.Id);
            });
        }
    }