Единство IAP без кода - PullRequest
       7

Единство IAP без кода

0 голосов
/ 20 марта 2019

Android не восстанавливал не расходуемый предмет, поэтому я добавляю слушателя IAP, теперь он восстанавливает мой не расходуемый предмет, но теперь, когда я покупаю расходный предмет, он дает мне двойную сумму, как я купил 50 золотых, но это дает мне 100 золотых, я думаю, что этопроисходит из-за того, что я использую один и тот же сценарий для прослушивателя IAP, но я не знаю, что я собираюсь кодировать для прослушивателя IAP. Я собираюсь поместить некоторое изображение и свой сценарий, чтобы вы могли понять более четко.

https://i.stack.imgur.com/ERV9r.png

https://i.stack.imgur.com/iVtXc.png

https://i.stack.imgur.com/FD8WO.png

https://i.stack.imgur.com/jQ8Rk.png

https://i.stack.imgur.com/MRqLj.png

    public void OnPurchaseCompleted(Product product)
{
    if(product != null)
    {
        switch (product.definition.id)
        {
            case "go50.ld":
                PlayerPrefs.SetInt("Gold", PlayerPrefs.GetInt("Gold") + 50);
                GoldText.text = PlayerPrefs.GetInt("Gold").ToString();
                CloudVariables.ImportantValues[3] = PlayerPrefs.GetInt("Gold");
                PlayGamesController.Instance.SaveCloud();
                Debug.Log("Completed");
                break;
            case "gold.100":
                PlayerPrefs.SetInt("Gold", PlayerPrefs.GetInt("Gold") + 100);
                GoldText.text = PlayerPrefs.GetInt("Gold").ToString();
                CloudVariables.ImportantValues[3] = PlayerPrefs.GetInt("Gold");
                PlayGamesController.Instance.SaveCloud();
                Debug.Log("Completed");
                break;
            case "gold.250":
                PlayerPrefs.SetInt("Gold", PlayerPrefs.GetInt("Gold") + 250);
                GoldText.text = PlayerPrefs.GetInt("Gold").ToString();
                CloudVariables.ImportantValues[3] = PlayerPrefs.GetInt("Gold");
                PlayGamesController.Instance.SaveCloud();
                Debug.Log("Completed");
                break;
            case "gold.500":
                PlayerPrefs.SetInt("Gold", PlayerPrefs.GetInt("Gold") + 500);
                GoldText.text = PlayerPrefs.GetInt("Gold").ToString();
                CloudVariables.ImportantValues[3] = PlayerPrefs.GetInt("Gold");
                PlayGamesController.Instance.SaveCloud();
                Debug.Log("Completed");
                break;
            case "gold.1000":
                PlayerPrefs.SetInt("Gold", PlayerPrefs.GetInt("Gold") + 1000);
                GoldText.text = PlayerPrefs.GetInt("Gold").ToString();
                CloudVariables.ImportantValues[3] = PlayerPrefs.GetInt("Gold");
                PlayGamesController.Instance.SaveCloud();
                Debug.Log("Completed");
                break;
            case "remove.ads":
                PlayerPrefs.SetInt("Remove", 1);
                Destroy(AdManager.Instance.gameObject);
                CloudVariables.ImportantValues[5] = PlayerPrefs.GetInt("Remove");
                PlayGamesController.Instance.SaveCloud();
                break;
            default:
                Debug.Log("Failed");
                break;
        }
    }
}

1 Ответ

0 голосов
/ 20 марта 2019

Из консоли Unity кажется, что вы запускаете событие дважды, проверьте, где вы вызываете это событие.Также на скриншоте IAPButton выбранное вами золото - 100, а не 50, возможно, в этом проблема.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...