Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by finneous · Mar 18, 2021 at 11:09 PM · script errorpackagesadvertisingmoney

'IUnityAdsListener' could not be found

Full error: error CS0246: The type or namespace name 'IUnityAdsListener' could not be found (are you missing a using directive or an assembly reference?)

Unity 2019.4.17f1

alt text Ads has been turned on

alt text Package Manager shows Advertisement 3.5.2 installed

My C# script:

using System.Collections; using System.Collections.Generic; using UnityEngine.Advertisements; using UnityEngine;

public class AdsManager : MonoBehaviour, IUnityAdsListener {

 string  googlePlayID        = "4055395";
 string  applePlayID         = "4055394";
 string  myVideoId           = "video";
 string  myRewardVideoId     = "rewardedVideo";
 string  myInterstatialId    = "Interstatial";
 string  myBannerId          = "Banner";
 bool    isTestGameMode  = false;

 // Start is called before the first frame update
 void Start()
 {
     Advertisement.AddListener (this);
     Advertisement.Initialize(googlePlayID, isTestGameMode);
     
 }

 public void DisplayInterstitialAds() {

     if (Advertisement.IsReady(myInterstatialId)) {
         Advertisement.Show(myInterstatialId);
         }
 }

 public void DisplayVideoAds() {

     Advertisement.Show(myRewardVideoId);

 }

 // Implement IUnityAdsListener interface methods:
 public void OnUnityAdsDidFinish (string surfacingId, ShowResult showResult) {
     // Define conditional logic for each ad completion status:
     if (showResult == ShowResult.Finished) {
         // Reward the user for watching the ad to completion.
         Debug.LogWarning ("You get a reward.");
     } else if (showResult == ShowResult.Skipped) {
         // Do not reward the user for skipping the ad.
         Debug.LogWarning ("You don't get a reward.");
     } else if (showResult == ShowResult.Failed) {
         Debug.LogWarning ("The ad did not finish due to an error.");
     }
 }

 public void OnUnityAdsReady (string surfacingId) {
     // If the ready Ad Unit or legacy Placement is rewarded, show the ad:
     if (surfacingId == myRewardVideoId) {
         // Optional actions to take when theAd Unit or legacy Placement becomes ready (for example, enable the rewarded ads button)
     }
 }

 public void OnUnityAdsDidError (string message) {
     // Log the error.
 }

 public void OnUnityAdsDidStart (string surfacingId) {
     // Optional actions to take when the end-users triggers an ad.
 } 

 // When the object that subscribes to ad events is destroyed, remove the listener:
 public void OnDestroy() {
     Advertisement.RemoveListener(this);
 }

}

screen-shot-2021-03-18-at-60031-pm.png (46.6 kB)
screen-shot-2021-03-18-at-60209-pm.png (230.7 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by finneous · Oct 08, 2021 at 02:56 PM

@PolymathicIndustries, I updated Advertisement to 3.7.5 (the latest and greatest), closing and re-opening the Unity editor two of times. No joy. I get the same error:

Assets/scripts/WWIFC.cs(28,37): error CS0246: The type or namespace name 'IUnityAdsListener' could not be found (are you missing a using directive or an assembly reference?)

I am at the same Unity version: 2019.4.17f1

alt text

alt text


screen-shot-2021-10-08-at-94317-am.png (159.4 kB)
screen-shot-2021-10-08-at-94659-am.png (345.2 kB)
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image PolymathicIndustries · Oct 16, 2021 at 08:51 PM 0
Share

@finneous I noticed that on line 8 that your code is not highlighted, as though you have it, but have not implemented it. I am not sure if this is your solution, but without seeing the rest of the code I cannot really say. Is there an initialization of "Advertisement" anywhere in your code?

avatar image
1

Answer by AirDemon · Nov 06, 2021 at 06:10 PM

I had this happen to me so I thought I would add to the thread in case anyone else comes across it. The adverts package was installed for me so I uninstalled, then re-installed and the errors went away.

Hope that's useful for someone.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by PolymathicIndustries · Oct 03, 2021 at 05:01 PM

Not sure if you still need a solution, but for future viewers, this is an update issue. To resolve this head over to the package manager, select Advertisements as shown in finneous' screenshots above, except this time you need to update it. Click on Advertisements and select/click on the latest/higher number. Once up date your package to the latest version the errors in your IDE will go away, having been resolved.

Hope this helps @finneous

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

115 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to give players "Real money"? 0 Answers

monetize a Youtube channel if showing Unity in videos ? 1 Answer

Account balance became zero 0 Answers

my app has impression more than 5K but ecpm is too low....How it increases ?? 1 Answer

Am I allowed to make money under 18 years old? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges