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. Dismiss Notice

Cannot Disable UnityAds Auto Initialization

Discussion in 'Unity Ads & User Acquisition' started by sharkyro, May 5, 2016.

  1. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hello everyone,

    I am currently facing the issue regarding ads not loading if the internet connection is not available on application startup. Unity version is 5.3.4f1

    I tried to use the workaround described here and here. Unfortunately I am unable to disable the auto-initialization of UnityAds... I have created the UnityAdsBuildProcessor script, placed it in the Editor folder and copy/pasted the following code inside:
    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEditor.Callbacks;
    3. using UnityEditor.Advertisements;
    4.  
    5. public class UnityAdsBuildProcessor : Editor
    6. {
    7.     [PostProcessScene]
    8.     public static void OnPostprocessScene()
    9.     {
    10.         AdvertisementSettings.enabled = true;
    11.         AdvertisementSettings.initializeOnStartup = false;
    12.  
    13.         throw new System.ArgumentException();
    14.     }
    15. }
    I even threw an exception to make sure this code is being executed. The console output is the one shown in the attached file... The Ads are initialized and only afterwards the exception is thrown (I assume the Ads are initialized before the code disabling Auto-initialization is executed).

    Any ideas on how to solve this issue?

    Thank you and Best Regards,
    Alex.
     

    Attached Files:

    _watcher_ likes this.
  2. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Bump...

    Does anyone have an alternative to disabling ads auto-initialization so that I can initialize after ensuring there is an internet connection?
     
  3. rasmus-unity

    rasmus-unity

    Unity Technologies

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    Sorry for late reply to this one. Correct, it seems that the [PostProcessScene] doesn't apply in editor playmode, however it should work when building on device, at least when I tested here.

    Did you try on a device?

    -Rasmus
     
  4. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hello Rasmus,

    You are right, I tested it in an Android build and it worked as intended.

    Thank you very much for your reply. Somehow I didn't have notifications enabled and didn't see it until now.

    Best Regards,
    Alex.
     
  5. AntonBreusov_TatemGames

    AntonBreusov_TatemGames

    Joined:
    Apr 20, 2016
    Posts:
    9
    Why there's a throw new System.ArgumentException() at the end?