Skip to content

Unity Plugin - MREC ads

MREC (medium rectangle) ads are 300×250 ads shown at the top or bottom of the screen. Use them on screens where the user pauses, like a level-complete screen. Like banners, they stay visible while users interact with your game.

Before you start, install and initialize the plugin.

1. Subscribe to events

Subscribe to the MREC events before calling LoadMrec, so you don't miss any. Unsubscribe when the object is disabled.

void OnEnable()
{
    A11MediationSDK.OnMrecLoaded     += OnLoaded;
    A11MediationSDK.OnMrecLoadFailed += OnLoadFailed;
    A11MediationSDK.OnMrecShown      += OnShown;
    A11MediationSDK.OnMrecShowFailed += OnShowFailed;
    A11MediationSDK.OnMrecClicked    += OnClicked;
    A11MediationSDK.OnMrecClosed     += OnClosed; // Not currently raised on Android or iOS
    A11MediationSDK.OnMrecRevenue    += OnRevenue;
}

void OnDisable()
{
    A11MediationSDK.OnMrecLoaded     -= OnLoaded;
    A11MediationSDK.OnMrecLoadFailed -= OnLoadFailed;
    A11MediationSDK.OnMrecShown      -= OnShown;
    A11MediationSDK.OnMrecShowFailed -= OnShowFailed;
    A11MediationSDK.OnMrecClicked    -= OnClicked;
    A11MediationSDK.OnMrecClosed     -= OnClosed;
    A11MediationSDK.OnMrecRevenue    -= OnRevenue;
}

2. Load the MREC

Pass a position. position defaults to A11BannerPosition.Bottom, and you can also use A11BannerPosition.Top.

A11MediationSDK.LoadMrec(AdUnitId, A11BannerPosition.Bottom);

3. Show the MREC

When OnMrecLoaded fires, call ShowMrec to display the MREC.

private void OnLoaded(string id, A11AdInfo info) => A11MediationSDK.ShowMrec(id);

4. Hide or destroy the MREC

The MREC stays on screen until you hide or destroy it. HideMrec hides it without destroying it, so you can call ShowMrec again without reloading. DestroyMrec removes it and frees its resources. To show it again after that, call LoadMrec.

A11MediationSDK.HideMrec(AdUnitId);    // Hide, keep loaded
A11MediationSDK.ShowMrec(AdUnitId);    // Show again
A11MediationSDK.DestroyMrec(AdUnitId); // Remove, for example in OnDestroy()

Full example

using UnityEngine;
using Aurion11.A11Mediation;

public class MrecExample : MonoBehaviour
{
    private const string AdUnitId = "your_mrec_ad_unit";

    void OnEnable()
    {
        A11MediationSDK.OnMrecLoaded     += OnLoaded;
        A11MediationSDK.OnMrecLoadFailed += OnLoadFailed;
        A11MediationSDK.OnMrecShown      += OnShown;
        A11MediationSDK.OnMrecShowFailed += OnShowFailed;
        A11MediationSDK.OnMrecClicked    += OnClicked;
        A11MediationSDK.OnMrecClosed     += OnClosed; // Not currently raised on Android or iOS
        A11MediationSDK.OnMrecRevenue    += OnRevenue;
    }

    void OnDisable()
    {
        A11MediationSDK.OnMrecLoaded     -= OnLoaded;
        A11MediationSDK.OnMrecLoadFailed -= OnLoadFailed;
        A11MediationSDK.OnMrecShown      -= OnShown;
        A11MediationSDK.OnMrecShowFailed -= OnShowFailed;
        A11MediationSDK.OnMrecClicked    -= OnClicked;
        A11MediationSDK.OnMrecClosed     -= OnClosed;
        A11MediationSDK.OnMrecRevenue    -= OnRevenue;
    }

    public void Load() => A11MediationSDK.LoadMrec(AdUnitId, A11BannerPosition.Bottom);

    void OnDestroy() => A11MediationSDK.DestroyMrec(AdUnitId);

    private void OnLoaded(string id, A11AdInfo info)      => A11MediationSDK.ShowMrec(id);
    private void OnLoadFailed(string id, A11AdLoadError e) => Debug.LogWarning($"MREC load failed: {e}");
    private void OnShown(string id, A11AdInfo info) { }
    private void OnShowFailed(string id, A11AdInfo info, A11AdShowError e) => Debug.LogWarning($"MREC show failed: {e}");
    private void OnClicked(string id, A11AdInfo info) { }
    private void OnClosed(string id, A11AdInfo info) { }
    private void OnRevenue(string id, A11AdInfo info)     => Debug.Log($"MREC revenue: {info.Revenue} {info.RevenueCurrency}");
}

MREC refresh

Caution

MDN11 currently does not support auto-refresh, so you need to load and show new MRECs manually. Refresh only while the MREC is on screen. Stop refreshing when the app goes to the background or the user moves to a screen without the MREC, so you don't request ads nobody sees. If your current mediation platform (for example MAX, LevelPlay or AdMob) has auto-refresh turned on for MRECs, you can't use MDN11 for MRECs yet. Call that platform's SDK directly instead.