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

    unity_0hWW885bnk03Dg

    Joined:
    Nov 28, 2021
    Posts:
    4
    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
    ,IUnityAdsListener
    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

    jlbaker2779

    Joined:
    Jun 14, 2020
    Posts:
    62
    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;
    6.  
    7. public class UnityAds : MonoBehaviour, IUnityAdsListener
    8. {
    9.     public void OnUnityAdsDidError(string message)
    10.     {
    11.         CustomEvent.Trigger(gameObject, "OnUnityAdsDidError", message);
    12.     }
    13.  
    14.     public void OnUnityAdsDidFinish(string placementId, ShowResult showResult)
    15.     {
    16.         CustomEvent.Trigger(gameObject, "OnUnityAdsDidFinish", placementId, showResult);
    17.     }
    18.  
    19.     public void OnUnityAdsDidStart(string placementId)
    20.     {
    21.         CustomEvent.Trigger(gameObject, "OnUnityAdsDidStart", placementId);
    22.     }
    23.  
    24.     public void OnUnityAdsReady(string placementId)
    25.     {
    26.         CustomEvent.Trigger(gameObject, "OnUnityAdsReady", placementId);
    27.     }
    28.  
    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.

    upload_2022-8-16_19-45-29.png