AdPlayDeveloper Docs
Core runtime

AdPlayManager

AdPlayManager is responsible for SDK initialization, server requests, image downloading, active ad caching, display, and engagement reporting.

Initializes the SDKPrepares the token, network layer, and active ad cache.
Gets ads from AdPlay serverRequests active ad content for the selected format.
Downloads ad imagesFetches creative assets before rendering them in Unity UI.
Caches active adsKeeps active content available during the session.
Ad units

Supported ad formats

Visual ad methods receive an AdPlayTemplate, while interstitial sound plays without a template. All methods return AdRequestInfo.

در SDK 2.5 حالت CreativeShowType.Permanent یا WeightBased را انتخاب کنید. بنر به BannerPlaceType نیز نیاز دارد (در این نمونه MainMenuSlot1). کال‌بک دکمه پاپ‌آپ، relatedAdId را به GetPopUp می‌دهد. canvas و templatePrefab را در Inspector تنظیم کنید.

Splash

Full-entry ad for launch, loading, or pre-menu moments.

GetSplash.cs
var result = await AdPlayManager.GetSplash(template, Adplay.Model.CreativeShowType.Permanent);

Banner

Small persistent placement for menus, stores, or calm screens.

GetBanner.cs
var result = await AdPlayManager.GetBanner(template, Adplay.Model.CreativeShowType.Permanent, Adplay.Model.BannerPlaceType.MainMenuSlot1);

PopUp

A larger template-driven ad, useful after transitions or on menu screens.

GetPopUp.cs
var result = await AdPlayManager.GetPopUp(template, relatedAdId);

PopUp Button

Shows only a button first. The popup opens after the player clicks.

GetPopUpButton.cs
var result = await AdPlayManager.GetPopUpButton(buttonTemplate, Adplay.Model.CreativeShowType.Permanent, OnClick);

Interstitial Sound

Plays an interstitial audio ad without creating a UI template.

GetInterstitialSound.cs
var result = await AdPlayManager.GetInterstitialSound(Adplay.Model.CreativeShowType.Permanent);
MethodUse forTemplate requirements
AdPlayManager.GetSplash(template, Adplay.Model.CreativeShowType.Permanent)Full-screen or launch-time splash adImage
AdPlayManager.GetBanner(template, Adplay.Model.CreativeShowType.Permanent, Adplay.Model.BannerPlaceType.MainMenuSlot1)Banner placement in a CanvasImage
AdPlayManager.GetPopUp(template, relatedAdId)Clickable popup ad with optional title, description, and button textImage, Button, RectTransform
AdPlayManager.GetPopUpButton(template, creativeShowType, onClick)Button-style entry point that can open a PopUp when clickedImage, Button
AdPlayManager.GetInterstitialSound(Adplay.Model.CreativeShowType.Permanent)Interstitial audio ad without UI template setupNone
Rendering layer

AdPlayTemplate

Templates are Unity UI prefabs that AdPlay fills with ad content.

FieldTypeUse
rectTransformRectTransformControls ad size and layout.
imageImageDisplays the ad creative image.
clickButtonButtonHandles ad click interaction.
titleTextRTLTextMeshProDisplays the ad title.
descriptionTextRTLTextMeshProDisplays the ad body text.
clickButtonTextRTLTextMeshProDisplays the call-to-action label.
Recommended hierarchy
Canvas
└── AdContainer
    └── AdPlayTemplate
        ├── AdImage
        ├── TitleText
        ├── DescriptionText
        └── ClickButton
            └── ButtonText
Response model

Results and errors

Every ad method returns AdRequestInfo so developers can handle empty inventory and integration mistakes.

AdRequestInfo.cs
bool IsSuccess;
AdRequestResultState State;
string ErrorMessage;
SuccessNoActiveAd - destroy the unused template and continue gameplayMissingRequiredTemplateField - fix Inspector referencesAdPlayIsNotInitialized - wait for OnGetAdsComplete
Sample implementation

SampleTest script

This sample shows how to wait for ads to finish loading, enable the test UI, instantiate templates, and call each supported ad method.

SampleTest.cs
using Adplay.Behaviours;
using Adplay.View;


using UnityEngine;
using UnityEngine.UI;
namespace Adplay.Test
{
    public class SampleTest : MonoBehaviour
    {
        [SerializeField] private Transform canvas;
        [SerializeField] private AdPlayTemplate templatePrefab;
        [SerializeField] private GameObject infoGameObject, sampleTestGameObject;
        [SerializeField] private Transform buttonParent;

        [Space]
        [SerializeField] private GameObject runtimeButtonsRoot;
        [SerializeField] private Button splashBtn, bannerBtn, popupButtonBtn, voiceBtn;


        private void OnEnable()
        {
            AdPlayManager.OnGetAdsComplete += OnGetAdsComplete;
            InitializeRuntimeButtons();
        }

        private void OnDisable()
        {
            AdPlayManager.OnGetAdsComplete -= OnGetAdsComplete;
        }

        private void OnGetAdsComplete()
        {
            infoGameObject.SetActive(false);
            sampleTestGameObject.SetActive(true);
            runtimeButtonsRoot.SetActive(true);
        }

        public async void ShowPopUpButtonPermanent()
        {
            var buttonTemplate = Instantiate(templatePrefab, canvas);

            var result = await AdPlayManager.GetPopUpButton(buttonTemplate, Model.CreativeShowType.Permanent, async (relatedAdId) =>
            {
                var template = Instantiate(templatePrefab, canvas);
                var result = await AdPlayManager.GetPopUp(template, relatedAdId);
                if (!result.IsSuccess)
                {
                    Debug.Log("No pop up permanent");
                }

            });
            if (!result.IsSuccess)
                Debug.Log("No pop up button permanent");
        }

        public async void ShowPopUpButtonWeightBased()
        {
            var buttonTemplate = Instantiate(templatePrefab, canvas);

            var result = await AdPlayManager.GetPopUpButton(buttonTemplate, Model.CreativeShowType.WeightBased, async (relatedAdId) =>
            {
                var template = Instantiate(templatePrefab, canvas);
                var result = await AdPlayManager.GetPopUp(template, relatedAdId);
                if (!result.IsSuccess)
                {
                    Debug.Log("No pop up permanent");
                }

            });
            if (!result.IsSuccess)
                Debug.Log("No pop up button permanent");
        }



        public async void ShowSplashPermanent()
        {
            var template = Instantiate(templatePrefab, canvas);

            var result = await AdPlayManager.GetSplash(template, Model.CreativeShowType.Permanent);
            if (!result.IsSuccess)
            {
                Debug.Log("No splash permanent");
            }
        }

        public async void ShowSplashWeightBased()
        {
            var template = Instantiate(templatePrefab, canvas);

            var result = await AdPlayManager.GetSplash(template, Model.CreativeShowType.WeightBased);
            if (!result.IsSuccess)
            {
                Debug.Log("No splash weight based");
            }
        }


        public async void ShowPermanantBanner()
        {
            var template = Instantiate(templatePrefab, canvas);

            var result = await AdPlayManager.GetBanner(template, Model.CreativeShowType.Permanent, Model.BannerPlaceType.MainMenuSlot1);
            if (!result.IsSuccess)
            {
                Debug.Log("No banner Permanent");
            }
        }

        public async void ShowWeightBasedBanner()
        {
            var template = Instantiate(templatePrefab, canvas);

            var result = await AdPlayManager.GetBanner(template, Model.CreativeShowType.WeightBased, Model.BannerPlaceType.MainMenuSlot1);
            if (!result.IsSuccess)
            {
                Debug.Log("No banner weight based");
            }
        }

        public async void ShowPermanentInterstitialSound()
        {
            var result = await AdPlayManager.GetInterstitialSound(Model.CreativeShowType.Permanent);
            if (!result.IsSuccess)
            {
                Debug.Log("No permanent interstitial sound");
            }
        }

        public async void ShowWeightBasedInterstitialSound()
        {
            var result = await AdPlayManager.GetInterstitialSound(Model.CreativeShowType.WeightBased);
            if (!result.IsSuccess)
            {
                Debug.Log("No WeightBased interstitial sound");
            }
        }



        private void InitializeRuntimeButtons()
        {
            splashBtn.onClick.AddListener(ShowSplashPermanent);
            bannerBtn.onClick.AddListener(ShowPermanantBanner);
            popupButtonBtn.onClick.AddListener(ShowPopUpButtonPermanent);
            voiceBtn.onClick.AddListener(ShowPermanentInterstitialSound);
        }

    }

}
Developer API

Public methods

These are the methods developers should use directly.

await AdPlayManager.GetSplash(AdPlayTemplate template, CreativeShowType creativeShowType) await AdPlayManager.GetBanner(AdPlayTemplate template, CreativeShowType creativeShowType, BannerPlaceType bannerPlaceType) await AdPlayManager.GetPopUp(AdPlayTemplate template, int relatedAdId) await AdPlayManager.GetPopUpButton(AdPlayTemplate template, CreativeShowType creativeShowType, Action<int> onClick) await AdPlayManager.GetInterstitialSound(CreativeShowType creativeShowType)