> ## Documentation Index
> Fetch the complete documentation index at: https://beta-guide.daro.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Banner Ads

> Implement banner ads in your Unity project.

## Banner Ad Format

* Ads fixed to the top or bottom of the screen.
* Places a native banner view over the Unity screen.

***

## Integrating Ads

<Steps>
  <Step title="Create Ad Instance">
    ```csharp theme={null}
    private DaroBannerAd ad;

    ad = new DaroBannerAd(
        "your-banner-ad-unit-id",
        DaroBannerSize.Standard,
        DaroBannerPosition.BottomCenter
    );
    ```
  </Step>

  <Step title="Register Event Handlers">
    ```csharp theme={null}
    ad.OnAdLoaded += info => Debug.Log("loaded");
    ad.OnAdFailedToLoad += error => Debug.LogWarning(error.Message);
    ad.OnAdShown += info => Debug.Log("shown");
    ad.OnAdImpression += info => Debug.Log("impression");
    ad.OnAdClicked += info => Debug.Log("clicked");
    ad.OnAdHidden += info => Debug.Log("hidden");
    ```
  </Step>

  <Step title="Load Ad">
    ```csharp theme={null}
    ad.Load();
    ```

    The banner is displayed automatically when loading succeeds. Call `Show()` only to display it again after `Hide()`.
  </Step>

  <Step title="Hide, Redisplay, or Dispose Ad">
    ```csharp theme={null}
    ad.Hide(); // Temporarily hides the banner.

    if (ad.IsReady())
    {
        ad.Show(); // Displays the hidden banner again.
    }

    ad.Dispose(); // Permanently releases the ad.
    ```
  </Step>
</Steps>

***

## Check Banner Display Area

Use `DaroBannerAd.GetScreenRect()` to read the native banner view's actual on-screen area.

The return value is `Rect?` in Unity screen pixels. It uses the same bottom-left origin convention as `Screen.safeArea`.

```csharp theme={null}
private System.Collections.IEnumerator WaitForBannerRect()
{
    for (var i = 0; i < 10; i++)
    {
        Rect? rect = ad?.GetScreenRect();
        if (rect.HasValue)
        {
            Debug.Log($"Banner rect: {rect.Value}");
            yield break;
        }

        yield return null;
    }
}
```

<Tip>
  Native banner layout completes a few frames after the automatic display following `Load()` or after a later `Show()`. `GetScreenRect()` can return `null` immediately after display or inside `OnAdShown`, so poll for a few frames when you need the measured area.
</Tip>

<Warning>
  `GetScreenRect()` returns `null` when the banner has not been shown yet, is hidden, or has been disposed. Re-check after rotation or resize because the value can change.
</Warning>

***

## Example

```csharp expandable theme={null}
using Daro;
using UnityEngine;

public sealed class BannerHost : MonoBehaviour
{
    [SerializeField] private string adUnitId = "your-banner-ad-unit-id";
    private DaroBannerAd ad;

    private void OnEnable()
    {
        ad = new DaroBannerAd(
            adUnitId,
            DaroBannerSize.Standard,
            DaroBannerPosition.BottomCenter
        );

        ad.OnAdLoaded += info => Debug.Log("banner loaded");
        ad.OnAdFailedToLoad += error => Debug.LogWarning(error.Message);
        ad.OnAdShown += info => Debug.Log("banner shown");
        ad.Load();
    }

    public void Hide()
    {
        ad?.Hide();
    }

    public void Show()
    {
        if (ad != null && ad.IsReady())
        {
            ad.Show();
        }
    }

    private void OnDisable()
    {
        ad?.Dispose();
        ad = null;
    }
}
```
