SDK reference
Go deeper into methods, templates, and result states.
Open page
AdPlayDeveloper Docs
This page gives developers the minimum steps needed to install dependencies, import Adplay-SDK-V1.2.unitypackage, configure the App Key, wait for initialization, and request Splash, Banner, PopUp, PopUpButton, and interstitial sound ads in Unity.
Assets -> Import Package -> Custom PackageWindows -> Ad Play -> App KeyWindow -> Ad Play -> Spawn Prefabراهنمای Unity همین صفحه برای اپ Android نیست. برای ادغام کتابخانه native از AAR و APIهای Android استفاده کنید.
AdPlay templates use RTLTMPro.RTLTextMeshPro for right-to-left title, description, and button text. Install RTLTMPro before importing or compiling the SDK.
https://github.com/hk1ll3r/RTLTMPro.git?path=/UPMPackage
"com.nosuchstudio.rtltmpro": "https://github.com/hk1ll3r/RTLTMPro.git?path=/UPMPackage"
private void OnEnable()
{
AdPlayManager.OnGetAdsComplete += HandleAdsLoaded;
}
private void OnDisable()
{
AdPlayManager.OnGetAdsComplete -= HandleAdsLoaded;
}
private void HandleAdsLoaded()
{
Debug.Log("Ads loaded successfully.");
}
using Adplay.Behaviours;
using Adplay.View;
using Model = Adplay.Model;
using UnityEngine;
[SerializeField] private Transform canvas;
[SerializeField] private AdPlayTemplate templatePrefab;
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");
}
}
نکته: BannerPlaceType جایگاه نمایش بنر را مشخص میکند و دارای ۶ مدل است: MainMenuSlot1، MainMenuSlot2، MainMenuSlot3، MatchMake، GameplaySlot1 و GameplaySlot2. برای نمایش تبلیغ در هر یک از این جایگاهها، باید با تیم ادپلی هماهنگ کنید.
using Adplay.Behaviours;
using Adplay.View;
using Model = Adplay.Model;
using UnityEngine;
[SerializeField] private Transform canvas;
[SerializeField] private AdPlayTemplate templatePrefab;
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");
}
}
using Adplay.Behaviours;
using Adplay.View;
using Model = Adplay.Model;
using UnityEngine;
[SerializeField] private Transform canvas;
[SerializeField] private AdPlayTemplate templatePrefab;
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");
}
using Adplay.Behaviours;
using Model = Adplay.Model;
using UnityEngine;
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");
}
}