Пример #1
0
    // ========================================================================== //

    /* public - [Do] Function
     * 외부 객체가 호출                         */
    public static void DoInit(Action <TENUM, bool> onPurchased)
    {
        if (_bInit)
        {
            return;
        }

        int iLen = PrimitiveHelper.GetEnumMax <TENUM>();

        if (iLen == 0)
        {
            Debug.LogWarning("Unity IAP : 상품을 등록해주세요!"); return;
        }

        StandardPurchasingModule pModule  = StandardPurchasingModule.Instance();
        ConfigurationBuilder     pBuilder = ConfigurationBuilder.Instance(pModule);

        TENUM[] eEnum = PrimitiveHelper.DoGetEnumType <TENUM>();

        for (int i = 0; i < iLen; i++)
        {
            string strProductID = eEnum[i].ToString();

            Debug.Log(strProductID);

            pBuilder.AddProduct(strProductID, ProductType.Consumable, new IDs {
                { strProductID, AppleAppStore.Name },
                { strProductID, GooglePlay.Name }
            });
        }

        IStoreListener pStoreListener = new SCUnityIAPService <TENUM>();

        UnityPurchasing.Initialize(pStoreListener, pBuilder);
        _EVENT_OnPurchased = onPurchased;
    }