Quantcast
Channel: Questions in topic: "ads"
Viewing all articles
Browse latest Browse all 1416

How do I fix my error with my addlistener?

$
0
0
I am given the following error with my script. CS1503 Argument 1: cannot convert from 'AdManager' to 'UnityEngine.Advertisements.IUnityAdsListener' My unity project that this script is attached to is up to date. (the ios and google play store ID's have been changed to keep them hidden) The error underlines "this" in the line that says "Advertisement.AddListener(this);" This is the code: > using System.Collections;> using System.Collections.Generic;> using UnityEngine;> using UnityEngine.Advertisements;>> public class AdManager : MonoBehaviour, IUnityAdsListener> {>> private string PlayStoreID = "1234567";> private string AppleID = "1234567";>> private string Ad = "video";> private string RewardAd = "rewardedVideo";>> public bool IsPlayStoreTarget;> public bool IsTest;> public void Start()> {> Advertisement.AddListener(this);>> if (IsPlayStoreTarget)> {> Advertisement.Initialize(PlayStoreID, IsTest);> }> else> {> Advertisement.Initialize(AppleID, IsTest);>> }> }> public void ShowAd()> {> if (Advertisement.IsReady(Ad))> {> Advertisement.Show(Ad);> }> else> {> return;> }> }> public void ShowRewardedAd()> {> if (Advertisement.IsReady(RewardAd))> {> Advertisement.Show(RewardAd);> }> else> {> return;> }>> }>> public void OnUnityAdsDidStart(string placementId)> {>> }> public void OnUnityAdsDidStart(string placementID, ShowResult ShowResult)> {> switch (ShowResult)> {> case ShowResult.Failed:> break;> case ShowResult.Finished:> if(placementID == RewardAd)> {> Debug.Log("Reward");> }> break;> case ShowResult.Skipped:> break; > }> }> }

Viewing all articles
Browse latest Browse all 1416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>