-
Notifications
You must be signed in to change notification settings - Fork 16
Advertisement
Enable Advertising module via menu Tools
> Pancake
> Wizard
> Advertisement
-
Ad Checking Interval
- ad availability check time. ex:
Ad Checking Interval = 8
checking load ad after each 8 second
- ad availability check time. ex:
-
Ad Loading Interval
- time between 2 ad loads. ex:
Ad Loading Interval = 15
the next call to load the ad must be 15 seconds after the previous one
- time between 2 ad loads. ex:
-
Current Network:
- the ad neitwork currently used to display ads
Install admob sdk via button Install_AdmobSdk
waiting for install package completed.
When completed you click button AddAdmobSymbol
to activation affect of admob plugin
-
Age Restrictd User
-
To ensure COPPA, GDPR, and Google Play policy compliance, you should indicate when a user is a child. If you know that the user is in an age-restricted category (i.e., under the age of 16), set the age-restricted user flag to true
-
If you know that the user is not in an age-restricted category (i.e., age 16 or older), set the age-restricted user flag to false
-
Decrale ad unit variable in context you want to display ad and call method show of them
public AdUnitVariable rewarded;
...
rewarded.Show();
- by default applovin will be used to show ad, you can use the following syntax to change network use to show ad
[SerializeField] private ScriptableEventString changeNetworkEvent;
changeNetworkEvent.Raise("admob");
banner.Show()
.OnDisplayed(() => { Debug.Log("[ADVERTISING]: banner displayed"); })
.OnClosed(() => { Debug.Log("[ADVERTISING]: banner closed"); })
.OnLoaded(() => { Debug.Log("[ADVERTISING]: banner loaded"); })
.OnFaildedToLoad(() => { Debug.Log("[ADVERTISING]: banner failded to load"); })
.OnFaildedToDisplay(() => { Debug.Log("[ADVERTISING]: banner failded to display"); });
rewarded.Show()
.OnDisplayed(() => { Debug.Log("[ADVERTISING]: rewarded displayed"); })
.OnClosed(() => { Debug.Log("[ADVERTISING]: rewarded closed"); })
.OnLoaded(() => { Debug.Log("[ADVERTISING]: rewarded loaded"); })
.OnFaildedToLoad(() => { Debug.Log("[ADVERTISING]: rewarded failded to load"); })
.OnFaildedToDisplay(() => { Debug.Log("[ADVERTISING]: rewarded failded to display"); })
.OnCompleted(() => { Debug.Log("[ADVERTISING]: rewarded completed"); })
.OnSkipped(() => { Debug.Log("[ADVERTISING]: rewarded skipped"); });
If in your game you can change the ad provider based on remote config. That is, you need to install both admob and applovin to be able to switch.
Now you need to create a scriptable that contains both admobVariable and applovinVariable and has a method that returns the variable type based on the bool variable value received from the remote config.
like this :
using Pancake.Monetization;
using Pancake.Scriptable;
namespace Pancake.SceneFlow
{
using UnityEngine;
[Searchable]
[CreateAssetMenu(fileName = "ad_reward_unit_wrapper.asset", menuName = "Pancake/AD/Reward Variable")]
[EditorIcon("scriptable_bind")]
public class RewardVariable : ScriptableObject
{
[SerializeField] private StringVariable remoteConfigUsingAdmob;
[SerializeField] private AdUnitVariable admobReward;
[SerializeField] private AdUnitVariable applovinReward;
public AdUnitVariable Context()
{
bool.TryParse(remoteConfigUsingAdmob, out bool usingAdmob);
return usingAdmob ? admobReward : applovinReward;
}
}
}
Then syntax to show ad change to
rewarded.Context().Show()
.OnDisplayed(() => { Debug.Log("[ADVERTISING]: rewarded displayed"); })
.OnClosed(() => { Debug.Log("[ADVERTISING]: rewarded closed"); })
.OnLoaded(() => { Debug.Log("[ADVERTISING]: rewarded loaded"); })
.OnFaildedToLoad(() => { Debug.Log("[ADVERTISING]: rewarded failded to load"); })
.OnFaildedToDisplay(() => { Debug.Log("[ADVERTISING]: rewarded failded to display"); })
.OnCompleted(() => { Debug.Log("[ADVERTISING]: rewarded completed"); })
.OnSkipped(() => { Debug.Log("[ADVERTISING]: rewarded skipped"); });
There is a problem with applovin according to their docs
- Interstitial
Fired when an interstitial ad is displayed (may not be received by Unity until the interstitial ad closes). Admob still work correctly
- Rewarded
For Applovin : Fired when a rewarded ad is displayed (may not be received by Unity until the rewarded ad closes). Admob still work correctly
This results in Interstitial and Rewarded OnDisplayed callbacks being called at ad closed instead of when the ad is displayed as desired.
If you need to define scripting symbols via scripts in the Editor so that your Editor scripts are affected by the change, you must use PlayerSettings.SetScriptingDefineSymbolsForGroup. However, there are some important details to note about how this operates.
Important: this method does not take immediate effect. Calling this method from script does not immediately apply and recompile your scripts. For your directives to take effect based on a change in scripting symbols, you must allow control to be returned to the Editor, where it then asynchronously reloads the scripts and recompiles them based on your new symbols and the directives which act on them.
So, for example, if you use this method in an Editor script, then immediately call BuildPipeline.BuildPlayer on the following line in the same script, at that point Unity is still running your Editor scripts with the old set of scripting symbols, because they have not yet been recompiled with the new symbols. This means if you have Editor scripts which run as part of your BuildPlayer execution, they run with the old scripting symbols and your player might not build as you expected.