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

Question What is the equal of Advertisement.RemoveListener (this) in the last ADS pack

Discussion in 'Unity Ads & User Acquisition' started by mfatihbarut, Jan 10, 2022.

Thread Status:
Not open for further replies.
  1. mfatihbarut

    mfatihbarut

    Joined:
    Apr 11, 2018
    Posts:
    1,058
    Hi all,
    I need to show 2 rewarded ads in my scenen.
    One, give another chance if you loose.
    Second give you double reward if you win.
    But as far as I see if I use the same script (rewarded ads button script in documentation) for those 2 buttons it is kinda have a conflict and even game crashes.
    How can I solve this problem, I saw Advertisement.RemoveListener (this) as answer in some forum answers but as far as I see it is not in the last version.
     
    NoeMrct likes this.
  2. NoeMrct

    NoeMrct

    Joined:
    Nov 19, 2021
    Posts:
    1
    Hi,
    I have the same problem, I made two scripts:
    - one that doubles the player's reward,
    - one that gives him a second life if he dies.

    When I watch an ad to get a second life everything works fine but if I change the scene and want to watch the ad to get double points I get this error :

    MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    UnityEngine.GameObject.GetComponent[T] () (at <07c89f7520694139991332d3cf930d48>:0)
    SecondLife.OnUnityAdsShowComplete (System.String adUnitId, UnityEngine.Advertisements.UnityAdsShowCompletionState showCompletionState) (at Assets/Scripts/Game/SecondLife.cs:47)
    UnityEngine.Advertisements.Platform.Editor.EditorPlatform+<>c__DisplayClass14_0.<Show>b__1 (System.Object sender, UnityEngine.Advertisements.Events.FinishEventArgs e) (at Library/PackageCache/com.unity.ads@4.0.0/Runtime/Advertisement/Platform/Editor/EditorPlatform.cs:156)


    I realised that when I call a script, it calls all the others, as if they were all linked to each other, I also searched a few hours on forums and found the same solution: "Advertisement.RemoveListerner(this)", but it no longer exists.
    If anyone has a solution I'm interested
     
    mfatihbarut likes this.
  3. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    624
    Please implement the "IUnityAdsShowListener" and Implement your logic in the "IUnityAdsShowListener.OnUnityAdsShowComplete" method.
     
  4. mfatihbarut

    mfatihbarut

    Joined:
    Apr 11, 2018
    Posts:
    1,058
    I couldn't see the relevance of this subject with mine. I need to check the loading before showing it, not after showing it.
    upload_2022-1-11_11-33-26.png
     
  5. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    624
    To check whether the ad is loaded, you can call the Load method to load an ad, and if the ad is loaded, IUnityAdsLoadListener.OnUnityAdsLoaded will be called.
     
  6. mfatihbarut

    mfatihbarut

    Joined:
    Apr 11, 2018
    Posts:
    1,058
    btw I found the problem. When you do something related to Canvas after ads video, game crashes.
    As far as I see, rewarded video wants to use the canvas which uses for showing the video.
    If you somehow disable that canvas or show another canvas it doesn't like it and even crashes the game.
     
    Last edited: Jan 11, 2022
    D12294 likes this.
  7. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    624
    We didn't hear this behavior before, would you be able to provide a reproducible sample project so we can check it?
     
Thread Status:
Not open for further replies.