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.

Question cant find a way to listen for a finished rewarded add

Discussion in 'Visual Scripting' started by unity_0hWW885bnk03Dg, Aug 13, 2022.

  1. unity_0hWW885bnk03Dg


    Nov 28, 2021
    i am making a double points for how long you were gone.

    i was looking at some normal scripting videos and they extended the MonoBehaiver class with
    and i cant do that with VisualScripting as far as i know they also right clicked it and added a few prebuilt functions for it to call when its done, started, an error or is ready.

    here is the link for the video and time of this part
    and 8:22.

    Also in the show Advertisement.Show with placementID,input and showListener,input node
    the showListener needs a showListener and i cant find that in the type option or the node libraries or in the variables i dont know what to put in it.

    can any one help with this issue of mine.
  2. jlbaker2779


    Jun 14, 2020
    I use custom events.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Advertisements;
    5. using Unity.VisualScripting;
    7. public class UnityAds : MonoBehaviour, IUnityAdsListener
    8. {
    9.     public void OnUnityAdsDidError(string message)
    10.     {
    11.         CustomEvent.Trigger(gameObject, "OnUnityAdsDidError", message);
    12.     }
    14.     public void OnUnityAdsDidFinish(string placementId, ShowResult showResult)
    15.     {
    16.         CustomEvent.Trigger(gameObject, "OnUnityAdsDidFinish", placementId, showResult);
    17.     }
    19.     public void OnUnityAdsDidStart(string placementId)
    20.     {
    21.         CustomEvent.Trigger(gameObject, "OnUnityAdsDidStart", placementId);
    22.     }
    24.     public void OnUnityAdsReady(string placementId)
    25.     {
    26.         CustomEvent.Trigger(gameObject, "OnUnityAdsReady", placementId);
    27.     }
    29.     void Start()
    30.     {
    31.         Advertisement.AddListener(this);
    32.     }
    33. }
    Then the trigger is set when the ad finishes and you can do whatever from there with your rewards.