playMaker

Author Topic: Playmaker/Unity Ads problem  (Read 4931 times)

Scarface

  • Playmaker Newbie
  • *
  • Posts: 5
Playmaker/Unity Ads problem
« on: May 11, 2021, 07:12:37 PM »
Hello, i've watched your Youtube tutorial on how to set up Playmaker and Unity ads, but i am having a real hard time trying to get the Unity ads to show using: "Unity Ads Show Add" action.
  Note: i am not a programmer but i managed to find a C sharp script online, i downloaded and used it in the same project am working-on, just to make sure i have everything set up properly; and it worked! Unity ads show up as expected. Only problem with this is that i don't know to reward my player since all my project is based upon Playmaker FSM's.
please answer me is that tutorial on your channel still viable?
am i missing something?
what should i do?
using Playmaker 1.9.1 P5. Unity 2019.4.16 f1 LTS

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Playmaker/Unity Ads problem
« Reply #1 on: May 12, 2021, 05:53:40 AM »
Hi,

 can you put the link of the video you watched? so that we are sure to look at the same content?

have you initialized unity ads properly? maybe that's what missing from your implementation?

BYe,

 Jean

Scarface

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Playmaker/Unity Ads problem
« Reply #2 on: May 12, 2021, 08:21:43 AM »
Here is the video link i've watched:
i do not know what you mean exactly by initializing Unity ads, but my setup is the same of the video and i am using "Unity Ads Initialize" at the Start state, i also used "Unity Ads is Ready" Action at Start state to check weither or not Unity Ads are ready but its not sending any events. Using a simple C sharp script, that i've downloaded from the internet (Link to C# script: https://github.com/c0mpi1er/UnityAds ) proves that i have everything set up properly on the Unity Ads Services side and in project.
Thank you. Hope you can help me with this one

CuriousRodeo

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Playmaker/Unity Ads problem
« Reply #3 on: May 12, 2021, 10:38:35 AM »
Is it possible that the actions are for the legacy ad placements and not for the new Ad Units?

Scarface

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Playmaker/Unity Ads problem
« Reply #4 on: May 14, 2021, 01:32:04 PM »
Hi,

 can you put the link of the video you watched? so that we are sure to look at the same content?

have you initialized unity ads properly? maybe that's what missing from your implementation?

BYe,

 Jean
Hello,  i've been trying to edit the action "UnityAds Show Ad" in last two days and now it is working, but with a warning message; " Assets\PlayMaker Custom Actions\UnityAds\MyUnityAdsShowAd.cs(78,44): warning CS0618: 'ShowOptions.resultCallback' is obsolete: 'Implement IUnityAdsListener and call Advertisement.AddListener()' " in console which i think means; "Unity Ads Show Ad" Action is a little bit outdated for  Unity ads Services 2021.
Note: the changes i made to "Unity Ads show Ad" are:
- implemented testMode bool to the Action
-implemented Advertisement Initialization to the Action, after removing all the IF statement in the code.
i hope you are looking into this issue. Thaank you

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Playmaker/Unity Ads problem
« Reply #5 on: May 17, 2021, 01:55:15 AM »
Hi,

 yes, Unity likely made some changes yet again..

 I'll have a look and provide a 2021 compatible version. thanks for looking into this!

Bye,

 Jean

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 772
Re: Playmaker/Unity Ads problem
« Reply #6 on: May 18, 2021, 09:02:52 AM »
Not only Unity would update its own advertising SDK (3.7.1 as of now) but with companies like Apple pushing for big changes, it's likely that old code will encounter compatibility issues.

Scarface

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Playmaker/Unity Ads problem
« Reply #7 on: May 21, 2021, 03:54:06 PM »
Hi,

 yes, Unity likely made some changes yet again..

 I'll have a look and provide a 2021 compatible version. thanks for looking into this!

Bye,

 Jean

Hope you going to find us a fix for this very soon. Thank you again

CuriousRodeo

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Playmaker/Unity Ads problem
« Reply #8 on: May 26, 2021, 01:51:39 PM »
Is it possible that this has been addressed somewhere else on this forum?

CuriousRodeo

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Playmaker/Unity Ads problem
« Reply #9 on: May 31, 2021, 01:27:13 PM »
I was able to get Unity Ads working by following this tutorial:


Now I have a similar problem as Scarface.  The Ads display, but I want to be able to reward my players for watching the full Ad.  Any advice on how to set a variable where (I've attempted to make the text red) in the script I am to reward the player, would be greatly appreciated.

Note:  I changed my GameIDs and SurfacingIDs to "Nunya"




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

public class AdsManager : MonoBehaviour, IUnityAdsListener
{

    #if UNITY_IOS
    private string gameId = "Nunya";
    #elif UNITY_ANDROID
    private string gameId = "Nunya";
    #endif

    bool testMode = true;

    string mySurfacingId = "Nunya";
   


    void Start()
    {
        Advertisement.AddListener(this);
        // Initialize the Ads service:
        Advertisement.Initialize(gameId, testMode);
    }

    public void ShowInterstitialAd()
    {
        // Check if UnityAds ready before calling Show method:
        if (Advertisement.IsReady())
        {
            Advertisement.Show(mySurfacingId);
            // Replace mySurfacingId with the ID of the placements you wish to display as shown in your Unity Dashboard.
        }
        else
        {
            Debug.Log("Interstitial ad not ready at the moment! Please try again later!");
        }
    }

    public void ShowRewardedVideo()
    {
        // Check if UnityAds ready before calling Show method:
        if (Advertisement.IsReady(mySurfacingId))
        {
            Advertisement.Show(mySurfacingId);
        }
        else
        {
            Debug.Log("Rewarded video is not ready at the moment! Please try again later!");
        }
    }

    // Implement IUnityAdsListener interface methods:
    public void OnUnityAdsDidFinish(string surfacingId, ShowResult showResult)
    {
        // Define conditional logic for each ad completion status:
        if (showResult == ShowResult.Finished)
        {
            // Reward the user for watching the ad to completion.
           

        }
        else if (showResult == ShowResult.Skipped)
        {
            // Do not reward the user for skipping the ad.
        }
        else if (showResult == ShowResult.Failed)
        {
            Debug.LogWarning("The ad did not finish due to an error.");
        }
    }

    public void OnUnityAdsReady(string surfacingId)
    {
        // If the ready Ad Unit or legacy Placement is rewarded, show the ad:
        if (surfacingId == mySurfacingId)
        {
            // Optional actions to take when theAd Unit or legacy Placement becomes ready (for example, enable the rewarded ads button)
        }
    }

    public void OnUnityAdsDidError(string message)
    {
        // Log the error.
    }

    public void OnUnityAdsDidStart(string surfacingId)
    {
        // Optional actions to take when the end-users triggers an ad.
    }

    // When the object that subscribes to ad events is destroyed, remove the listener:
    public void OnDestroy()
    {
        Advertisement.RemoveListener(this);
    }
}

CuriousRodeo

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Playmaker/Unity Ads problem
« Reply #10 on: May 31, 2021, 01:49:15 PM »
I have made a work around that will work for me, for now.

PlayerPrefs.SetInt ("reward", 2);

I can then get the Playerpref with Playmaker and save the variable.

Yay!