You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PlumberUltimateAds/Assets/Scripts/Ads Scripts/AdmobUIHandler.cs

72 lines
1.7 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AdmobUIHandler : MonoBehaviour
{
public Text admobInitText, admobInitTextBool;
public Text iAdLoadingTextBool, rAdLoadingTextBool;
public Text iAdLoadedTextBool, rAdLoadedTextBool;
private void Start()
{
AdsManager.Instance.OnAdmobInitializedEvent += OnAdmobInitComplete;
AdsManager.Instance.OniAdLoading += OniAdStartedLoading;
AdsManager.Instance.OnrAdLoading += OnrAdStartedLoading;
AdsManager.Instance.OniAdLoaded += OniAdLoaded;
AdsManager.Instance.OnrAdLoaded += OnrAdLoaded;
}
private void OnAdmobInitComplete()
{
admobInitText.text = "Admob Initialized";
admobInitTextBool.text = "true";
}
private void OniAdStartedLoading(bool val)
{
iAdLoadingTextBool.text = val.ToString();
}
private void OniAdLoaded(bool val)
{
iAdLoadedTextBool.text = val.ToString();
}
private void OnrAdStartedLoading(bool val)
{
rAdLoadingTextBool.text = val.ToString();
}
private void OnrAdLoaded(bool val)
{
rAdLoadedTextBool.text = val.ToString();
}
public void InitAdmob()
{
AdsManager.Instance.InitializeAdmob();
}
public void RequestrAd()
{
AdsManager.Instance.LoadRewardedAdWithDelay();
}
public void RequestiAd()
{
AdsManager.Instance.LoadInterstitialAdWithDelay();
}
public void ShowiAd()
{
AdsManager.Instance.ShowInterstitialAd("placement_name");
}
public void ShowrAd()
{
AdsManager.Instance.ShowRewardedAd(RewardedTypes.Color);
}
}