Search Unity

Rewarded ads button disabled

Discussion in 'Unity Ads & User Acquisition' started by Romyo75, Sep 12, 2021.

  1. Romyo75

    Romyo75

    Joined:
    Sep 8, 2021
    Posts:
    14
    Hi, i used rewarded ads button on my app. I use unity ads. But rewarded ads button is not clickable. It looks it is disabled. Why?
     
  2. SuperArcherG

    SuperArcherG

    Joined:
    Aug 21, 2021
    Posts:
    3
    Make sure you are loading the ad. The script from the examples unity provides do not automatically load an ad on start. Note to only load ads after initializing the ad system.
     
  3. Romyo75

    Romyo75

    Joined:
    Sep 8, 2021
    Posts:
    14
    any tutorial?
     
    PsijicNine likes this.
  4. Romyo75

    Romyo75

    Joined:
    Sep 8, 2021
    Posts:
    14
    how can i do that?
     
    PsijicNine likes this.
  5. LIU_Hanyang96

    LIU_Hanyang96

    Unity Technologies

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

    You can refer to this document to find how to integrate UnityAds SDK into your project.
     
  6. Romyo75

    Romyo75

    Joined:
    Sep 8, 2021
    Posts:
    14
    I copy and paste the reawrded ads example and puts my ads id to the inspector. But the rewarded ads button is not clickable
     
    PsijicNine likes this.
  7. Romyo75

    Romyo75

    Joined:
    Sep 8, 2021
    Posts:
    14
    Please help me
     
    PsijicNine likes this.
  8. Romyo75

    Romyo75

    Joined:
    Sep 8, 2021
    Posts:
    14
    Problem solved
     
  9. adrianfielding

    adrianfielding

    Joined:
    Jun 11, 2013
    Posts:
    8
    I am having the same issue. How did you solve it?
     
    PsijicNine likes this.
  10. Asaturyan21

    Asaturyan21

    Joined:
    Aug 4, 2022
    Posts:
    2
    How did you solve it? please help me.
     
    PsijicNine likes this.
  11. Asaturyan21

    Asaturyan21

    Joined:
    Aug 4, 2022
    Posts:
    2
    Have you solved it?
     
  12. aylin_unity3d

    aylin_unity3d

    Unity Technologies

    Joined:
    Apr 6, 2015
    Posts:
    48
  13. Hugocodman

    Hugocodman

    Joined:
    Aug 8, 2023
    Posts:
    4
    Hi I have the same probleme as you
    yow did you solve it? this is my code
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using UnityEngine.Advertisements;
    4. using UnityEngine.SceneManagement;
    5.  
    6. public class RewardedAdsButton : MonoBehaviour, IUnityAdsLoadListener, IUnityAdsShowListener
    7. {
    8.     [SerializeField] Button _showAdButton;
    9.     [SerializeField] string _androidAdUnitId = "Rewarded_Android";
    10.     [SerializeField] string _iOSAdUnitId = "Rewarded_iOS";
    11.     string _adUnitId = null;
    12.  
    13.     void Awake()
    14.     {
    15. #if UNITY_IOS
    16.         _adUnitId = _iOSAdUnitId;
    17. #elif UNITY_ANDROID
    18.         _adUnitId = _androidAdUnitId;
    19. #endif
    20.  
    21.         _showAdButton.interactable = false;
    22.     }
    23.  
    24.     public void LoadAd()
    25.     {
    26.         Debug.Log("Chargement de la publicité : " + _adUnitId);
    27.         Advertisement.Load(_adUnitId, this);
    28.     }
    29.  
    30.     public void OnUnityAdsAdLoaded(string adUnitId)
    31.     {
    32.         Debug.Log("Publicité chargée : " + adUnitId);
    33.  
    34.         if (adUnitId.Equals(_adUnitId))
    35.         {
    36.             _showAdButton.onClick.RemoveAllListeners();
    37.             _showAdButton.onClick.AddListener(ShowAd);
    38.             _showAdButton.interactable = true;
    39.         }
    40.     }
    41.  
    42.     public void ShowAd()
    43.     {
    44.         _showAdButton.interactable = false;
    45.         Advertisement.Show(_adUnitId, this);
    46.     }
    47.  
    48.     public void OnUnityAdsShowComplete(string adUnitId, UnityAdsShowCompletionState showCompletionState)
    49.  
    50.     {
    51.         LoadAd();
    52.         if (adUnitId.Equals(_adUnitId) && showCompletionState.Equals(UnityAdsShowCompletionState.COMPLETED))
    53.         {
    54.             Debug.Log("Publicité récompensée Unity Ads terminée");
    55.             SceneManager.LoadScene(0);
    56.  
    57.             LoadAd();
    58.         }
    59.     }
    60.  
    61.     public void OnUnityAdsFailedToLoad(string adUnitId, UnityAdsLoadError error, string message)
    62.     {
    63.         Debug.Log($"Erreur lors du chargement de l'unité de publicité {adUnitId} : {error.ToString()} - {message}");
    64.     }
    65.  
    66.     public void OnUnityAdsShowFailure(string adUnitId, UnityAdsShowError error, string message)
    67.     {
    68.         Debug.Log($"Erreur lors de l'affichage de l'unité de publicité {adUnitId} : {error.ToString()} - {message}");
    69.     }
    70.  
    71.     public void OnUnityAdsShowStart(string adUnitId) { }
    72.     public void OnUnityAdsShowClick(string adUnitId) { }
    73.  
    74.     void OnDestroy()
    75.     {
    76.         _showAdButton.onClick.RemoveAllListeners();
    77.     }
    78. }
    79.  
     
    PsijicNine likes this.
  14. Yasuyuki

    Yasuyuki

    Unity Technologies

    Joined:
    Sep 11, 2014
    Posts:
    153
    Can you please check if the Unity Ads SDK has already completed initialize() before load()?
    https://docs.unity.com/ads/manual/UnityAPI#Initialize