设置 Unity IAP【Setting up Unity IAP】

如果进不去的网页,请自备梯子!英文版在文末!

设置 Unity IAP

注意:屏幕截图和菜单选项可能因发行版本而异。

概述

本文档介绍了如何激活应用内购买(IAP)。 统一内购 软件包提供编码和无代码方法,您可以设置这些方法: – 允许用户在您的游戏中购买物品。- 连接到商店,以便您可以从这些购买中获得收入。 以下是这些步骤的概述:
  • 为该游戏定义您的应用内购买策略。
  • 将您的项目设置为 Unity 服务。
  • 激活 IAP 以自动安装软件包。
  • 配置设置。
  • 创建并编目您要出售的游戏内物品。
  • 使用无代码 IAP 按钮为用户提供一种购买商品的方式。然后,一旦您的逻辑工作正常,就可以考虑自定义按钮的外观和感觉。或者使用脚本化 IAP 获取丰富的 API 来增强此过程。
    设置 Unity IAP【Setting up Unity IAP】
  • 将您的应用连接到相关的应用商店,例如 Google、Apple 或 Android。
  • 将商品添加到商店。
把它们放在一起:
  • 使用此文档、支持和 IAP 论坛中的指导配置您的 IAP。
  • 测试一切。
  • 让它活着。
您还可以使用 In-App Purchasing API 执行其中许多步骤,或微调您创建的内容。

入门

注意:Samsung Galaxy 商店现已过时,Unity 应用内购买包 4.0.0 及更高版本不再支持它。本 Samsung Galaxy 商店配置指南仅适用于 IAP 包版本 3.1.0 及更早版本。如果您使用的是 Unity IAP 包 4.0.0 及更高版本并且想要实施三星 Galaxy 商店,请改用Unity 分发平台
  1. 在 Unity 编辑器中打开您的 Unity 项目。
  2. 选择Window\General\Services。将出现服务窗口。
  3. 创建项目 ID,然后将项目连接到组织。
  4. 回答铜牌 合规性问题。
  5. 服务窗口将显示服务列表。单击应用程序内购买
设置 Unity IAP【Setting up Unity IAP】
服务
  1. 项目设置窗口出现。
设置 Unity IAP【Setting up Unity IAP】
项目设置
  1. 单击In-App Purchase Settings旁边的切换开关到ON
这将从包管理器自动安装 IAP 包,为您提供新功能和菜单项以帮助您管理 IAP。

下一步

定义您的应用内购买策略

您的任务是创建供玩家购买的物品并获得他们的标识符。 为了让这一切发生在场景 ,您必须使用指定的格式将产品标识符(字符串)绑定到您销售的每件商品。一些商店要求您为其商店自定义产品 ID 。

规划:

  • 定义您的策略以确定用户何时/如何购买东西
  • 定义您的定价策略
  • 定义产品类型(订阅者、消耗品、非消耗品)

在哪里了解更多

内购样品

  1. IAP 项目设置页面中,单击从选项中打开包管理器
  2. 导航到In App Purchasing。在右侧的信息面板上,找到Samples
  3. 展开示例,然后单击导入
设置 Unity IAP【Setting up Unity IAP】
样品

论坛教程

请参阅 Unity 论坛

Unity 学习 IAP 课程

有关更多指导,请参阅 Unity Learn IAP 课程

故障排除

如何解决升级过程中的编译错误

如果您要从 Unity IAP 版本 2.x 升级到未来版本,请注意重要事项。 如果从 Unity IAP(com.unity.purchasing + Asset Store 插件)版本 2.x 更新到未来版本,请完成以下操作以解决编译错误:
  • 移动IAPProductCatalog.jsonBillingMode.jsonAssets/Plugins/UnityPurchasing/Resources/Assets/Resources/
  • 移动AppleTangle.csGooglePlayTangle.cs从:“资产/插件/UnityPurchasing/生成”到:Assets/Scripts/UnityPurchasing/generated
  • 删除所有剩余的资产商店 项目中的插件文件夹和文件Assets/Plugins/UnityPurchasing

常见的 Unity IAP 集成编译器错误

以下错误消息可能表明 Unity Cloud Services 窗口中禁用了 Unity IAP,或者 Unity 已与 Internet 断开连接: * CS0246 * System.Reflection.ReflectionTypeLoadException * UnityPurchasing/Bin/Stores.dll *UnityEngine.Purchasing 要解决这些错误: 通过关闭然后重新打开来重新加载“服务”窗口。重新加载后,确保启用 Unity IAP 服务。如果这不起作用,请尝试断开并重新连接到 Internet,然后重新登录到 Unity 服务并重新启用 Unity IAP。 注意:您必须具有项目的所有者管理者角色。  

Setting up Unity IAP

Note: Screen shots and menu choices may differ between release versions.

Overview

This document explains how to activate In-App Purchasing (IAP). The Unity IAP  package provides coded and codeless approaches that you set up to: – Allow users to buy items in your games. – Connect to stores so that you can obtain revenue from these purchases. Here is an overview of the steps:
  • Define your In-app purchase strategy for this game.
  • Setup your project as a Unity service.
  • Activate IAP to automatically install the package.
  • Configure settings.
  • Create and catalog your the in-game items that you want to sell.
  • Use the Codeless IAP button to give users a way to buy items. Then, once you have the logic working, consider customizing the button look and feel. Or use the scripted IAP for a rich API to enhance this process. 
    设置 Unity IAP【Setting up Unity IAP】
  • Connect your app to the relevant app-stores, such as Google, Apple, or Android.
  • Add items to the stores.
Put it all together:
  • Configure your IAP using guidance from this doc, support, and the IAP forum.
  • Test everything.
  • Make it live.
You can also do many of these steps, or fine tune what you create, with the In-App Purchasing API.

Getting Started

Note: The Samsung Galaxy store is now obsolete and is no longer supported in the Unity In-App Purchasing package 4.0.0 and higher. This guide to configure the Samsung Galaxy store only applies to the IAP package version 3.1.0 and earlier. If you’re using the Unity IAP package 4.0.0 and higher and want to implement a Samsung Galaxy store, use the Unity Distribution Platform instead.
  1. Open your Unity project in the Unity Editor.
  2. Choose Window\General\Services. The services window will appear.
  3. Create a Project ID, then connect the project to an organization.
  4. Answer the COPPA  compliance questions.
  5. The services window will display a list of services. Click In-App Purchasing.
设置 Unity IAP【Setting up Unity IAP】
Services
  1. The Project Settings window appears.
设置 Unity IAP【Setting up Unity IAP】
Project Settings
  1. Click the toggle next to In-App Purchasing Settings to ON.
This will automatically install the IAP package from the package manager, providing you with new features and menu items to help you manage IAP.

Next Steps

Define your In-App Purchase strategy

Your task will be to create items for players to buy and obtain their identifiers. To make this happen behind the scenes , you must tie product identifiers (strings) to each item you are selling, using a specified format. Some stores require that you customize the Product ID for their stores.

Planning:

  • Define your strategy to determinhe when/how users can buy things
  • Define your pricing strategy
  • Define the types of products (subscriber, consumable, non consumable)

Where to learn more

IAP Samples

  1. From the IAP Project Settings Page, click Open Package Manager from Options.
  2. Navigate to In App Purchasing. On the right information panel, find Samples.
  3. Expand Samples, then click Import.
设置 Unity IAP【Setting up Unity IAP】
Samples

Forum tutorials

See the Unity forum.

Unity Learn IAP classes

Refer to the Unity Learn IAP classes for more guidance.

Troubleshooting

How to resolve compilation errors during upgrades

Important notes if you are upgrading from Unity IAP version 2.x to future versions. If updating from Unity IAP (com.unity.purchasing + the Asset Store plugin) versions 2.x to future versions, complete the following actions in order to resolve compilation errors:
  • Move IAPProductCatalog.json and BillingMode.jsonfrom Assets/Plugins/UnityPurchasing/Resources/ to Assets/Resources/
  • Move AppleTangle.cs and GooglePlayTangle.cs FROM: ‘Assets/Plugins/UnityPurchasing/generated’ TO: Assets/Scripts/UnityPurchasing/generated.
  • Remove all remaining Asset Store  plugin folders and files in Assets/Plugins/UnityPurchasing from your project.

Common Unity IAP integration compiler errors

The following error messages may indicate that Unity IAP is disabled in the Unity Cloud Services window, or that Unity is disconnected from the Internet: * CS0246 * System.Reflection.ReflectionTypeLoadException * UnityPurchasing/Bin/Stores.dll * UnityEngine.Purchasing To resolve these errors: Reload the Services window by closing, then reopening it. Once reloaded, ensure that the Unity IAP service is enabled. If this doesn’t work, try disconnecting and reconnecting to the Internet, then sign back into Unity Services and re-enable Unity IAP. Note: You must have an Owner or Manager role for the project.