【问题标题】:Codeless IAP unity无代码 IAP 统一
【发布时间】:2019-03-20 12:51:58
【问题描述】:

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;
        }
    }
}

【问题讨论】:

    标签: unity3d in-app-purchase


    【解决方案1】:

    在 Unity 控制台中,您似乎触发了两次事件,请检查您调用该事件的位置。同样在 IAPButton 屏幕截图中,您选择的金币是 100,而不是 50,也许这就是问题所在。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多