unity rewarded ads tutorial unity ads tutorial 2024

Unity Rewarded Ads Tutorial | Unity Ads Tutorial 2024

Unity Rewarded Ads Tutorial | Unity Ads Tutorial 2024 :- This tutorial provides a step-by-step approach to implementing Unity’s rewarded ads in your Unity project. You will learn how to set up Unity Ads within the Unity dashboard, integrate the Unity Ads SDK into your project, and implement rewarded ad functionality. The guide covers how to trigger ads, manage user rewards, and ensure a smooth integration that enhances player engagement and boosts monetization. By the end of the tutorial, you’ll be equipped to effectively use rewarded ads to create value for users and generate revenue for your app.

CONTACT US TO ADD 10 AD NETWORKS TO YOUR UNITY PROJECT – CHARGES APPLY

FULL UNITY REWARDED ADS SCRIPT

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using UnityEngine.UI;
using UnityEngine.Advertisements;

public class RewardedAds : MonoBehaviour, IUnityAdsInitializationListener, IUnityAdsLoadListener, IUnityAdsShowListener
{

    public string gameID = "";
    public string rewardedID = "";

    [SerializeField] bool testMode = true;


    // Start is called before the first frame update
    void Start()
    {

        InitializeAds();
        LoadRewardedAd();

    }

    public void InitializeAds()
    {

        if (!Advertisement.isInitialized && Advertisement.isSupported)
        {
            Advertisement.Initialize(gameID, testMode, this);
        }

    }

    public void OnInitializationComplete()
    {
        Debug.Log("Unity Ads initialization complete.");
    }

    public void OnInitializationFailed(UnityAdsInitializationError error, string message)
    {
        Debug.Log($"Unity Ads Initialization Failed: {error.ToString()} - {message}");
    }

    public void LoadRewardedAd()
    {
        // IMPORTANT! Only load content AFTER initialization (in this example, initialization is handled in a different script).
        Advertisement.Load(rewardedID, this);
    }

    public void OnUnityAdsAdLoaded(string adUnitId)
    {
        // Optionally execute code if the Ad Unit successfully loads content.
    }

    public void ShowRewardedAd()
    {
        // Then show the ad:
        Advertisement.Show(rewardedID, this);
    }

    public void OnUnityAdsShowComplete(string adUnitId, UnityAdsShowCompletionState showCompletionState)
    {
        if (adUnitId.Equals(rewardedID) && showCompletionState.Equals(UnityAdsShowCompletionState.COMPLETED))
        {
            Debug.Log("Unity Ads Rewarded Ad Completed");
            // Grant a reward.
        }
    }

    // Implement Load and Show Listener error callbacks:
    public void OnUnityAdsFailedToLoad(string adUnitId, UnityAdsLoadError error, string message)
    {
        Debug.Log($"Error loading Ad Unit {adUnitId}: {error.ToString()} - {message}");
        // Use the error details to determine whether to try to load another ad.
        LoadRewardedAd();
    }

    public void OnUnityAdsShowFailure(string adUnitId, UnityAdsShowError error, string message)
    {
        Debug.Log($"Error showing Ad Unit {adUnitId}: {error.ToString()} - {message}");
        // Use the error details to determine whether to try to load another ad.
        LoadRewardedAd();
    }

    public void OnUnityAdsShowStart(string adUnitId) { }
    public void OnUnityAdsShowClick(string adUnitId) { }

}

In completing this Unity Rewarded Ads tutorial, you’ve gained the skills to effectively integrate and manage rewarded ads in your Unity project. By setting up Unity Ads, configuring the SDK, and implementing rewarded ad functionality, you can enhance user engagement and drive monetization. The strategies you’ve learned will help you offer compelling incentives to players while maintaining a positive user experience. Continue to refine your ad implementation based on user feedback and performance metrics to optimize your app’s success and revenue potential.

***CHECK FULL VIDEO TUTORIAL***

Visit www.UnitySourceCode.store

Leave a Reply

Shopping cart

0
image/svg+xml

No products in the cart.

Continue Shopping