Search Unity

(SOLVED) Corner Case for UnityAdsHacks.cs

Discussion in 'Unity Ads & User Acquisition' started by Christop, Dec 9, 2014.

  1. Christop

    Christop

    Joined:
    Aug 21, 2012
    Posts:
    60
    Hi
    I was playing around with this source
    https://github.com/wcoastsands/unity-ads-demo

    There is a UnityAdsHacks class which allegedly tries to fix some problems with UnityAds when the add is not removed properly and the game freezes. IT does that by assuming the OnApplicationPause() is called when the Ads enter/exit.

    I found that this is not true for pictureAds. In the editor or on the device(when the network connection) was lost sometimes picture ads appear (it show a overplay picture with a close icon top right and no video).
    When showing these kind of Ads the OnApplicationPause() is not called. So this might break some logic if you assumed that it is always called.

    It this something you can confirm @Nikkolai @UnityAds team.

    Thanks
    Dimi
     
  2. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    Right, picture ads don't use web view. The only instance that we've seen this issue with is with video ads. Are you experience this issue with picture ads?
     
  3. Christop

    Christop

    Joined:
    Aug 21, 2012
    Posts:
    60
    Not exactly, but I tight in a flag with the Unityhacks approach so I know when the app went into the background because of a user action or because of the advertisement. There are different things happening in each case.
    If there is a picture ad this flag is never reset.
    The bad thing is that you never know if this add is a picture add or not. Can I disable picture ads for my defaultVideoZone (just to stay future safe?)

    Thanks
    Dimi
     
  4. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    Right, like I said before, picture ads don't use web view, regardless of which zone ID is used to show them. The defaultVideoAndPictureZone is initially configured to show both video and picture ads, but they're shown in very different ways.

    When a video ad is shown, the web view in which it's shown causes the app to lose focus. When that happens, OnApplicationPause(true) is called. When you close the ad, the focus is returned to the app, and OnApplicationPause(false) is called.

    In some cases, UnityAds.ResumeGame() is not called when the app regains focus. This workaround ensures that values for volume and timescale are returned to an initial value of 1. The app does not lose focus when picture ads are shown, and are therefore not subject to this issue.
     
  5. Christop

    Christop

    Joined:
    Aug 21, 2012
    Posts:
    60
    Ok thanks for the clarifications. I reverted to using the callback called when the app return in order to set any internal variables.
     
    unity-nikkolai likes this.