首页 > 解决方案 > Unity IAP:如何编写脚本来为当前版本的 Unity 提供无代码 IAP 功能?

问题描述

我想实现无代码 IAP,人们可以在 Mac App Store 中购买非消耗性 Unity 应用程序。

我正在使用2017.4.27f。Codeless IAP 的文档指出不需要太多的脚本。这是我第一次在应用程序中实现 IAP。我不知道完成交易所需的所有功能。

Unity 提供的 Unity IAP 示例最后一次更新是在 2016 年 1 月使用 Unity 5.3。

https://bitbucket.org/Unity-Technologies/unity-iap-samples/src/master/

在我导入资产后,它们会产生以下脚本错误。

Assets/Plugins/UnityPurchasing/script/IAPDemo.cs(20,19): error CS0234: The type or namespace name `Store' does not exist in the namespace `UnityEngine'. Are you missing an assembly reference?

Assets/Plugins/UnityPurchasing/script/IAPDemo.cs(630,38): error CS0246: The type or namespace name `ILoginListener' could not be found. Are you missing an assembly reference?

Assets/Plugins/UnityPurchasing/script/IAPDemo.cs(634,25): error CS0246: The type or namespace name `UserInfo' could not be found. Are you missing an assembly reference?

Assets/Plugins/UnityPurchasing/script/IAPDemo.cs(647,29): error CS0246: The type or namespace name `UserInfo' could not be found. Are you missing an assembly reference?

这是 Unity 提供的产生错误的脚本。

https://bitbucket.org/Unity-Technologies/unity-iap-samples/src/master/UnityIAPDemo/Assets/Scripts/UnityIAPDemo.cs

如果这些错误已得到纠正,此脚本能否与当前版本的 Unity for IAP 一起使用?

我已经搜索了几天以获取有关 Unity IAP 的更多最新信息。我只找到了向人们展示如何创建 Unity IAP 按钮并使用 Debug.log 语句为已完成的购买和失败的购买创建过程的视频。他们都没有提供可以用作学习这些东西的起点的示例脚本。

引用的 Unity 教程也很旧。我得到同样的错误。

https://unity3d.com/learn/tutorials/topics/ads-analytics/integrating-unity-iap-your-game

我在这里或游戏开发堆栈交换中没有找到任何涉及基本 Unity IAP 信息的问题。

我找不到来自 Unity 的最新教程。

看完 Unity IAP 文档后,我完全迷失了。它假设人们了解 IAP 交易如何运作的基础知识。

标签: c#unity3din-app-purchase

解决方案


推荐阅读