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

Rewarded Ads Button not interacteble

Discussion in 'Unity Ads & User Acquisition' started by Effsty, Oct 16, 2021.

  1. Effsty

    Effsty

    Joined:
    Jun 24, 2016
    Posts:
    29
    I'm using Unity 2019.4.17f1 and Advertisement package version 3.7.5 as can be seen below.



    I enabled ADS in Services and Enabled test mode.

    Globally, I created an Empty GameObject called AdsInitializer and attached the AdsInitializer.cs script from here: https://unityads.unity3d.com/help/unity/integration-guide-unity



    I add the Android ID and IOS ID from the Ad Units in the Unity Dashboard and run the scene.

    Everything looks fine:



    Now I create a Button and add the RewardedAdsButton.cs script from https://unityads.unity3d.com/help/unity/integration-guide-unity on it.

    Looks like this:



    In the Game view, the button is not interactable under any circumstances. After the Awake() function in RewardedAdsButton.cs sets interactable to false it stays like that. Why can't I press the button and get the "All seems to be working Unity screen"?
     
  2. Unity_Jae

    Unity_Jae

    Unity Technologies

    Joined:
    Aug 30, 2021
    Posts:
    50
    Hello Effsty,

    Sorry to hear that you are having a problem. Also thank you for providing detailed information.
    Did you call `LoadAd()` method? Why I am checking this is because,

    Code (CSharp):
    1.     void Awake()
    2.     {
    3.         // Get the Ad Unit ID for the current platform:
    4.         _adUnitId = (Application.platform == RuntimePlatform.IPhonePlayer)
    5.             ? _iOsAdUnitId
    6.             : _androidAdUnitId;
    7.  
    8.         //Disable button until ad is ready to show
    9.         _showAdButton.interactable = false;
    10.     }
    11.  
    12.     // Load content to the Ad Unit:
    13.     public void LoadAd()
    14.     {
    15.         // IMPORTANT! Only load content AFTER initialization (in this example, initialization is handled in a different script).
    16.         Debug.Log("Loading Ad: " + _adUnitId);
    17.         Advertisement.Load(_adUnitId, this);
    18.     }
    19.  
    20.     // If the ad successfully loads, add a listener to the button and enable it:
    21.     public void OnUnityAdsAdLoaded(string adUnitId)
    22.     {
    23.         Debug.Log("Ad Loaded: " + adUnitId);
    24.  
    25.         if (adUnitId.Equals(_adUnitId))
    26.         {
    27.             // Configure the button to call the ShowAd() method when clicked:
    28.             _showAdButton.onClick.AddListener(ShowAd);
    29.             // Enable the button for users to click:
    30.             _showAdButton.interactable = true;
    31.         }
    32.     }
    33.  
    1. In Awake, the script inactivates the button. `//Disable button until ad is ready to show _showAdButton.interactable = false;`
    2. When UnityAds is loaded, it will set _showAdButton.Interactable = true
    3. However, If you are not calling `LoadAd()` the button will stay inactive.

    Hence, could you try calling LoadAd() method? After calling the function, If you still having any problems, please leave a comment.
     
  3. Dhruv_Shirdhankar

    Dhruv_Shirdhankar

    Joined:
    Mar 7, 2022
    Posts:
    2
    i have called the LoadAd function in the adsmanager script but still it isn't loading. the button stays inactive. This setup works perfectly fine the unity editor but doesn't work in the android. This problem occurs with rewarded ads and banner ads but not with interstitial ads.
     
  4. fuadshahmuradov

    fuadshahmuradov

    Joined:
    Nov 20, 2019
    Posts:
    10
    I have the same problem, were you able to fix it? If yes, please how?
     
    PsijicNine and tom41_10tt like this.
  5. tom41_10tt

    tom41_10tt

    Joined:
    Oct 7, 2021
    Posts:
    9
    Hey, I am a bit late but:
    Just call the LoadAd(); function of your script after Unity Ads initialization is completed.
    I did this by calling the LoadAd(); function in the void OnInitializationComplete :)