Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

unity ads 3.7.5

Discussion in 'Unity Ads & User Acquisition' started by piggybank1974, Aug 14, 2021.

  1. piggybank1974

    piggybank1974

    Joined:
    Dec 15, 2015
    Posts:
    621
    I'm in the process of upgrading my game from unity 2019.2.10F1 to unity 2020.3.6F1, I know this is not the latest version, but that should not matter, I shelved the old Ad system I was using 2.00.8, and as I'm using a newer version I could use ads 3.7.5 and installed it from the latest installed button much easier than before anyways.

    I'm using the guide https://unityads.unity3d.com/help/unity/integration-guide-unity#implementing-rewarded-ads
    as a base, but as usual with the documentation from unity, shall we say it's challenging.

    I got everything hooked up as I thought I wanted it, but the completion method OnUnityAdsShowComplete does not get called "I'm only testing this thew the editor at this time." to that end, I did hook up

    Code (CSharp):
    1.      
    2. ShowOptions mOptions = new ShowOptions();
    3.      mOptions.resultCallback = OnUnityAdsShowComplete;
    4.  
    5.    Advertisement.Show(mAndroidAdUnitID, mOptions);
    6.  
    and use my old method using the new name

    Code (CSharp):
    1.   private void OnUnityAdsShowComplete(ShowResult result)
    2.   {
    3.    switch (result)
    4.    {
    5.     case ShowResult.Finished:
    6.      if (mHeroComponent != null)
    7.       mManagers.CanvasManager.HUD.Health += 1000;
    8.      else
    9.      {
    10.       mManagers.Project.Device.Health += 1000;
    11.       mManagers.Project.Device.Save();
    12.      }
    13.  
    14.      mManagers.CanvasManager.LevelDialog.PnlAdInitialisation.SetActive(false);
    15.      mManagers.CanvasManager.LevelDialog.PnlAwards.SetActive(true);
    16.      mManagers.Project.CurrentSelectableObject = mManagers.CanvasManager.LevelDialog.AwardSelectableObject;
    17.      break;
    18.  
    19.     case ShowResult.Failed:
    20.      Debug.Log("I swear this has never happened to me before");
    21.      break;
    22.    }
    23.   }
    but why is this not getting called? and unity barks at me saying mOptions.resultCallback is obsolete and to see IUnitydsListner, which is not even mentioned in the guide.
     
  2. LIU_Hanyang96

    LIU_Hanyang96

    Unity Technologies

    Joined:
    Jul 12, 2021
    Posts:
    113
    Hi piggybank1974,

    I am sorry for that experience. However, for 3.7.5, we recommend you use IUnityAdsLoadListener and IUnityAdsShowListener. Then, you can use codes like "Advertisement.Show(placementId, this);" to set up the callback functions.

    For more information, you can refer to these documents.
     
  3. piggybank1974

    piggybank1974

    Joined:
    Dec 15, 2015
    Posts:
    621
    @LIU_Hanyang96

    Thanks for the reply, I'm actually using these three events IUnityAdsInitializationListener, IUnityAdsLoadListener, IUnityAdsShowListener.

    The problem is that I had to use

    Code (CSharp):
    1.  
    2. ShowOptions mOptions = new ShowOptions();
    3.  mOptions.resultCallback = OnUnityAdsShowComplete;
    4.  
    5.  Advertisement.Show(mAndroidAdUnitID, mOptions);
    6.  
    To get the callback to work through the editor, I've not tested it in field trials, at the moment as I'm coding other things, but I wanted at the very least to see if the new code for 3.7.5 was working over 2.0.8.

    Nowhere does it mention that using the documentation code will not fire the OnUnityAdsShowComplete when using it through the unity editor, but the above code does work through the editor, but unity says it is obsolete?
     
  4. LIU_Hanyang96

    LIU_Hanyang96

    Unity Technologies

    Joined:
    Jul 12, 2021
    Posts:
    113
    Hi,

    In 3.7.5, you need to pass the show listener into Show() function, you can refer to this "public static void Show(string adUnitId, ShowOptions showOptions, IUnityAdsShowListener showListener)", and "void OnUnityAdsShowComplete(string adUnitId, UnityAdsShowCompletionState showCompletionState);" is a function inside the interface "IUnityAdsShowListener". With this, you should be able to fire the completion callback normarlly.
     
  5. piggybank1974

    piggybank1974

    Joined:
    Dec 15, 2015
    Posts:
    621
    @LIU_Hanyang96

    Sorry for the late reply, but I thought I would do more updates to the game before came back to this.

    I decided to upload the code "SceneManagerComponent" that the new Advertisement plugin 3.7.5 is used with.

    So I created a little dialog to show the stages "and screenshots" of what is happening, and I left the code in SceneManagerComponent s you could see it.

    First I know that if you have the advertisement plugin, but you are running it "thought the editor", it will effectively do nothing, you get the standard screen that unity produces with the close button, although I would have thought it would still call the OnUnityAdsShowComplete event, it does not.

    But as the game is designed and built for android, this is what's important. when running it on android "on a real device", once I call Advertisement.Initialize in the Start event, nothing else happens as you can see from the Android screenshot, it just sits there, so in effect, the game just freezes, on the windows version I get the Level Dialog and then I could press play button and play the level.

    I did originally have the Advertisement.Initialize in Awake event but again did the same. I decided to put it on here as once an initial level is loaded all subsequent levels come from this scene so it does not get unloaded until the player does not want to play anymore, and goes back to the Main Menue Scene.

    any help on this would be great as I would like to use 3.7.5 and not have to backtrack to 2.0.0.8 as I thin the previous version I was using.
     

    Attached Files:

  6. LIU_Hanyang96

    LIU_Hanyang96

    Unity Technologies

    Joined:
    Jul 12, 2021
    Posts:
    113
    Hi,

    As I have read through your codes, I think in "OnUnityAdsAdLoaded", you tried to call "show", but you did not check the placementId. Maybe sometimes only Banner Ads are loaded, and this function is called. May you provide me your apk file or full device logs, and I can check more details for your project. In addition, when you press the showing button, what is returned by this line "Debug.Log("IsAdsInitialalized: " + this.IsAdsInitialalized)"?