Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by afot2020 · Jan 04, 2021 at 04:26 PM · unityads

UnityAds Use both Rewarded and Interstitial Video Ad

Hi everyone, I implemented Unity Ads according to the Manual and it is working. However, I try to use both Reward Video Ad and Interstitial Video Ad and there seems to be an Override, because both functions reward the Player. For testing the Functionality, I have two Buttons in my scene, the first one is connected to DisplayInterstitialAD() and the second one is connected to DisplayRewardVideoAD(). No matter which one is called, they both call OnUnityAdsDidFinish(...) and thus the Reward Function. Is it wrong to implement both Methods in one Script? I know one Workaround would be to use a bool connected to the buttons, but I think that I implemented it wrong and Unity has another solution for combining the two ad formats, right?

This is the Script:

 using UnityEngine;
 using UnityEngine.Advertisements;
 
 public class AdManager : MonoBehaviour, IUnityAdsListener
 {
     public static AdManager instance;
     public bool TestMode = true;
 
     string game_ID = "xxxxxxx";
     string myPlacementId = "rewardedVideo";
 
     private void Start()
     {
         Advertisement.Initialize(game_ID, TestMode);
         Advertisement.AddListener(this);
     }
 
     public void DisplayInterstitialAD()
     {
         Advertisement.Show();
     }
 
     public void DisplayRewardVideoAD()
     {
         Advertisement.Show(myPlacementId);
     }
 
 
     public void OnUnityAdsDidFinish(string placementId, ShowResult showResult)
     {
         // Define conditional logic for each ad completion status:
         if (showResult == ShowResult.Finished)
         {
             PayReward_1();
         }
         else if (showResult == ShowResult.Skipped)
         {
             // Do not reward the user for skipping the ad.
         }
         else if (showResult == ShowResult.Failed)
         {
             Debug.LogWarning("The ad did not finish due to an error.");
         }
     }
 
     public void PayReward_1()
     {
         //Paying the Reward to the Player
     }
 }


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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Kofiro · Jan 04, 2021 at 09:55 PM

Within your OnUnityAdsDidFinish method do this

 if(placementId.Equals(myPlacementId))
 {
     if(showResult == ShowResult.Finished)
     {
         PayReward_1();
     }
 }
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 afot2020 · Jan 05, 2021 at 09:40 AM 0
Share

Thank you, but that would be the same as using a bool right? The problem with that solution is that the Reward Ad is skippable, while the Interstitial is not. I am looking for a solution that differentiate between the skippable Reward Video and the unskippable Interstitial. I always worked with Google's Admob where you have two different Ad Objects for those two Formats, way easier to handle.

avatar image
0

Answer by afot2020 · Jan 05, 2021 at 09:58 AM

Ok I found the solution. I have to use two different Placement IDs, which I generate in the Unity Dashboard. And then I initialize and call them like this:

 string PlacementId_reward = "rewardedVideo";
 string PlacementId_interstitial = "interstitial";
 public void DisplayInterstitialAD()
 {
     Advertisement.Show(PlacementId_interstitial);
 }

 public void DisplayRewardAD()
 {
     Advertisement.Show(PlacementId_reward);
 }

For detecting the Reward I can then use the solution of Kofiro posted above. Thanks!

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 Kofiro · Jan 05, 2021 at 10:15 AM 0
Share

You're welcome!

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

114 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

Related Questions

unity ads only shows up to 8 ads in a row in my app 1 Answer

No UnityAds displaying in AppStore version? 0 Answers

Error when building Game 0 Answers

Is there some way we can Place Ads in Games Using Unity Video Component 0 Answers

What could cause Unity Ads to crash after a couple of reward videos? 0 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