This guide can be useful if you decide to use a custom Ads Provider together with Ads Manager.
The setup of a custom provider can be tricky. We highly recommend you use default providers if you’re not an experienced user.
First of all, we should create a template for the new provider and add it to the project.
Create a new folder in the path Assets/Watermelon Core/Modules/Monetization/Scripts/Advertisement/Providers
and name it as you want. In my case, it will be “Guide”.
Inside the created folder, create two scripts GuideContainer, and GuideHandler (instead of Guide use the name of your provider)
Editor script should be placed in Editor folder
Open AdProvider.cs file and add a new element to the enum.
Now, you should register a new Define. This will allow you to include SDK-related code in the project without having the SDK installed.
[Define("MODULE_GUIDE", "ExampleNamespace.ScriptName")]
To register the created ads handler you should add a new element to the GetProviders method in AdsManager class.
#if MODULE_GUIDE
new GuideHandler(AdProvider.Guide),
#endif
Warning: Use the name of the handler and element from the enum that you created before.
Open AdsSettings.cs and add a serializable container variable and public property that will return this variable.
[SerializeField, Hide] GuideContainer guideContainer;
public GuideContainer GuideContainer => guideContainer;
Open AdsSettingsEditor.cs file and add a new element to the adsContainers array.
new EditorGuideContainer("Guide", "guideContainer"),
Parameters:
If you’ve done everything right, the new provider should appear in Monetization Settings
Now you’re ready to implement custom SDK to the project. Follow the guide provided by the developer of the SDK, but adapt it to the structure created before the Handler script.
You can check how AdMobHandler and UnityAdsLegacyHandler were made and use this knowledge to set up your Handler.
For the correct work of Ads Manager, you should implement the following logic: