---
title: "展示付费墙"
description: "了解如何使用 Adapty SDK 在 Unity 应用中展示付费墙。"
---

如果你已经使用付费墙编辑工具自定义了付费墙，则无需在移动端代码中手动处理渲染逻辑来向用户展示它。这类付费墙已包含展示内容和展示方式的完整配置。

:::warning

本指南适用于**新版付费墙编辑工具**，需要 Adapty SDK 3.3.0 或更高版本。

如需展示远程配置付费墙，请参阅[渲染通过远程配置设计的付费墙](present-remote-config-paywalls)。

:::

要展示付费墙，请对通过 [`CreatePaywallView`](unity-get-pb-paywalls#fetch-the-view-configuration-of-paywall-designed-using-paywall-builder) 方法创建的 `view` 调用 `view.Present()` 方法。每个 `view` 只能使用一次。如需再次展示同一付费墙，请重新调用 `CreatePaywallView` 以创建新的 `view` 实例。

:::warning

复用同一个 `view` 而不重新创建，可能会导致 `AdaptyUIError.viewAlreadyPresented` 错误。
:::

```csharp showLineNumbers title="Unity"
view.Present((error) => {
  // handle the error
});
```
:::tip

想看看 Adapty SDK 在移动应用中的实际集成示例吗？欢迎查看我们的[示例应用](sample-apps)，其中演示了完整的集成流程，包括展示付费墙、完成购买以及其他基本功能。

:::

## 显示对话框 \{#show-dialog\}

当付费墙视图在 Android 上展示时，请使用此方法代替原生弹窗。在 Android 上，普通弹窗会显示在付费墙视图后方，导致用户看不到。该方法可确保在所有平台上对话框正确显示于付费墙之上。

```csharp showLineNumbers title="Unity"
var dialog = new AdaptyUIDialogConfiguration()
    .SetTitle("Close paywall?")
    .SetContent("You will lose access to exclusive offers.")
    .SetDefaultActionTitle("Stay")
    .SetSecondaryActionTitle("Close");

AdaptyUI.ShowDialog(view, dialog, (action, error) => {
    if (error == null) {
        if (action == AdaptyUIDialogActionType.Secondary) {
            // User confirmed - close the paywall
            view.Dismiss();
        }
        // If primary - do nothing, user stays
    }
});
```

## 配置 iOS 展示样式 \{#configure-ios-presentation-style\}

通过向 `Present()` 方法传入 `iosPresentationStyle` 参数来配置付费墙在 iOS 上的展示方式。该参数接受 `AdaptyUIIOSPresentationStyle.FullScreen`（默认值）或 `AdaptyUIIOSPresentationStyle.PageSheet`。

```csharp showLineNumbers title="Unity"
view.Present(AdaptyUIIOSPresentationStyle.PageSheet, (error) => {
    // handle the error
});
```