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.

  1. 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”.

  2. Inside the created folder, create two scripts GuideContainer, and GuideHandler (instead of Guide use the name of your provider)

    image.png

    GuideContainer template

    GuideHandler template

    Editor script should be placed in Editor folder

    EditorGuideContainer template

  3. Open AdProvider.cs file and add a new element to the enum.

    image.png

  4. 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")]
    

    image.png

  5. 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.

    image.png

  6. 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;
    
  7. Open AdsSettingsEditor.cs file and add a new element to the adsContainers array.

    new EditorGuideContainer("Guide", "guideContainer"),
    

    image.png

    Parameters:

    1. The name that will be displayed in the editor
    2. Name of the serialized variable added before to AdsSettings.cs script
  8. If you’ve done everything right, the new provider should appear in Monetization Settings

    image.png

    image.png

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:

Initialization

Call in the main thread

Banner callbacks

Interstitial callbacks