-
Notifications
You must be signed in to change notification settings - Fork 12
Advertising
VirtueSky edited this page Sep 4, 2024
·
13 revisions
(Tested with applovin > v5.11.3 and google admob > v8.5.2)
- Create AdClient and AdVariable
- Choose AdNetwork Max or Admob
- You can click install sdk if your project doesn't have it yet.
- Add Scripting Define Symbols to use
(For Admob, you can get the test Id by going to Context Menu
and selecting Get Id Test
)
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using VirtueSky.Ads;
public class AdsManager : MonoBehaviour
{
public TextMeshProUGUI textNoti;
public AdUnitVariable banner;
public AdUnitVariable inter;
public AdUnitVariable reward;
public void ShowBanner()
{
Debug.Log(banner.IsReady());
banner.Show();
}
public void ShowInter()
{
if (inter.IsReady())
{
LogMessage("inter is ready");
inter.Show().OnCompleted(() => { LogMessage("inter is completed"); });
}
else
{
LogMessage("Inter is not ready");
}
}
public void ShowReward()
{
if (reward.IsReady())
{
LogMessage("reward is ready");
reward.Show().OnCompleted(() => { LogMessage("Reward is completed"); }).OnSkipped(() => { LogMessage("reward is skipped"); });
}
else
{
LogMessage("reward is not ready");
}
}
void LogMessage(string message)
{
textNoti.text = message;
Debug.Log(message);
}
}