Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Unity Ads Documentation Change Request - Add RemoveListener to provided Reward Button Code

Discussion in 'Unity Ads & User Acquisition' started by jmurnanedev, May 7, 2020.

  1. jmurnanedev

    jmurnanedev

    Joined:
    Apr 30, 2020
    Posts:
    4
    Hi,

    Just a small request, could you add an onDestroy function that removes the listener to the reward button code listed here?

    https://unityads.unity3d.com/help/unity/integration-guide-unity#implementing-rewarded-ads

    Something like this:


    Code (CSharp):
    1. public void OnDestroy ()
    2. {
    3.    Advertisement.RemoveListener (this);
    4. }
    Otherwise, the whole thing breaks when you change scene and back again - so if you have it on a "game over" screen as in my case, once you restart the scene, the button breaks for future use unless you remove the listener when the object is destroyed.

    A small issue but seems like it's not immediately obvious what the issue is and could definitely save a bit of digging for the solution!

    Thanks :)
     
  2. kyle-unity

    kyle-unity

    Unity Technologies

    Joined:
    Jan 6, 2020
    Posts:
    336
    Hey @jmurnanedev that's a great suggestion and in fact we've been having internal discussions about this as it's definitely the most common bug we see here on the forums. Hopefully the documentation team will add this soon! :)
     
  3. kocakberatfurkan

    kocakberatfurkan

    Joined:
    Sep 14, 2019
    Posts:
    5
    Hello, I cant use RemoveListener function. Is it no longer in use ?
     
    toert likes this.