I'm new to Unity and I'm a beginner. Unity ads have completed, but instead of the letter "E" and "T" I want the ad to come out by clicking the button. how can I write a code for it?
using System.Collections.Generic; using UnityEngine; using UnityEngine.Monetization;
public class AdController : MonoBehaviour { private string store_id = "3049359";
private string video_ad = "video";
private string banner_ad = "bannerAd";
void Start()
{
Monetization.Initialize (store_id, true);
}
void Update()
{
if (Input.GetKeyDown (KeyCode.E)) {
if (Monetization.IsReady (video_ad)) {
ShowAdPlacementContent ad = null;
ad = Monetization.GetPlacementContent (video_ad) as ShowAdPlacementContent;
if (ad != null) {
ad.Show ();
}
}
}
if (Input.GetKeyDown (KeyCode.T)) {
if (Monetization.IsReady (banner_ad)) {
ShowAdPlacementContent ad = null;
ad = Monetization.GetPlacementContent (video_ad) as ShowAdPlacementContent;
if (ad != null) {
ad.Show ();
}
} } } }

