- Home /
unity ads playmaker - review
Hello comunity,
I have some playmaker commands for unity ads but they are obsolete.
this one is UnityAds_Initialize.cs
using UnityEngine;
using System.Collections.Generic;
using UnityEngine.Advertisements;
using HutongGames.PlayMaker;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("UnityAds")]
[Tooltip("Initializes UnityAds, this must be called before any other UnityAds Actions")]
public class UnityAds_Initialize : FsmStateAction
{
[RequiredField]
public FsmString GameId;
public bool adTestMode;
public bool adPrecache;
public override void Reset()
{
adTestMode = false;
adPrecache = false;
}
public override void OnEnter()
{
#if UNITY_IOS || UNITY_ANDROID
Advertisement.Initialize (GameId.Value,adTestMode);
Advertisement.allowPrecache = (adPrecache);
#endif
Finish();
}
}
}
And the other file is:
using UnityEngine;
using System.Collections.Generic;
using UnityEngine.Advertisements;
using HutongGames.PlayMaker;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("UnityAds")]
[Tooltip("Checks to see if a Unity advert is availible")]
public class UnityAds_ShowAd : FsmStateAction
{
public bool usePlacementID;
public FsmString adPlacementID;
public bool pauseEngineWhileAd;
public FsmEvent adUnavailableEvent;
public FsmEvent adResultCompleted;
public FsmEvent adResultFailed;
public FsmEvent adResultSkipped;
public override void Reset()
{
usePlacementID = false;
pauseEngineWhileAd = false;
}
public void HandleShowResult (ShowResult result)
{
switch (result)
{
case ShowResult.Finished:
Fsm.Event(adResultCompleted);
break;
case ShowResult.Skipped:
Fsm.Event(adResultSkipped);
break;
case ShowResult.Failed:
Fsm.Event(adResultFailed);
break;
}
}
public override void OnEnter()
{
#if UNITY_IOS || UNITY_ANDROID
bool adAvailable = Advertisement.isReady();
if(adAvailable)
{
if (pauseEngineWhileAd)
{
if (usePlacementID)
{
Advertisement.Show(adPlacementID.Value, new ShowOptions {pause = true, resultCallback = HandleShowResult});
} else {
Advertisement.Show(null, new ShowOptions {pause = true, resultCallback = HandleShowResult});
}
} else {
if (usePlacementID)
{
Advertisement.Show(adPlacementID.Value, new ShowOptions {resultCallback = HandleShowResult});
} else {
Advertisement.Show(null, new ShowOptions {resultCallback = HandleShowResult});
}
}
}
else
{
Fsm.Event(adUnavailableEvent);
}
#endif
Finish();
}
}
}
The erros unity is giving me are:
Assets/PlayMaker/Actions/UnityAds/UnityAds_Initialize.cs(27,47): warning CS0618: UnityEngine.Advertisements.Advertisement.allowPrecache' is obsolete:
Advertisement.allowPrecache is no longer supported and does nothing'
Assets/PlayMaker/Actions/UnityAds/UnityAds_ShowAd.cs(46,58): warning CS0618: UnityEngine.Advertisements.Advertisement.isReady(string)' is obsolete:
Use Advertisement.IsReady method instead'
Assets/PlayMaker/Actions/UnityAds/UnityAds_ShowAd.cs(53,106): warning CS0618: UnityEngine.Advertisements.ShowOptions.pause' is obsolete:
ShowOptions.pause is no longer supported and does nothing, video ads will always pause the game'
Assets/PlayMaker/Actions/UnityAds/UnityAds_ShowAd.cs(55,91): warning CS0618: UnityEngine.Advertisements.ShowOptions.pause' is obsolete:
ShowOptions.pause is no longer supported and does nothing, video ads will always pause the game' Assets/scripts/controle ads.cs(26,35): warning CS0618: UnityEngine.Advertisements.Advertisement.isReady(string)' is obsolete:
Use Advertisement.IsReady method instead'
I can not code a single line so I was hoping someone could help me fixing this new commands on this script I have.
Can anyone help?
Thanks
Doug.
You might want to reformat your scripts to make them readable.
Sorry about that, maybe now I did it right. Thanks for the tip.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Why is Unity Ads not showing an ad in unity 5.2? 5 Answers
How to write debug log to txt file? 3 Answers