Skip to content
serdarakay edited this page Nov 26, 2024 · 27 revisions

GitHub version license

Gamedistribution.com Unity HTML5 SDK plugin

This is the documentation of the "Gamedistribution.com Unity HTML5 SDK plugin" project for adding the SDK within your Unity WebGL game.

Gamedistribution.com is the biggest broker of high quality, cross-platform games. We connect the best game developers to the biggest publishers.

Running into any issues?

Check out the F.A.Q. within the Wiki of the github repository before mailing to [email protected].

Implementation within games

  1. Download and import the .unitypackage into your game (download here).

  2. Drag the prefab "GameDistribution" into your scene.

  3. Copy your GAME_KEY in your GameDistribution developer's control panel (in the 'Upload' tab), at developer.gamedistribution.com

  4. Open the prefab and replace the GAME_KEY value with your own key.

  5. Use GameDistribution.Instance.ShowAd() to show an advertisement.

  6. Use GameDistribution.Instance.ShowRewardedAd() to show a rewarded advertisement.

  7. Use GameDistribution.Instance.PreloadRewardedAd() to preload a rewarded advertisement

  8. Make use of the events GameDistribution.OnResumeGame and GameDistribution.OnPauseGame for resuming/pausing your game in between ads.

  9. Make use of the event GameDistribution.OnPreloadRewardedVideo for checking the availability of rewarded advertisement after called GameDistribution.Instance.PreloadRewardedAd()

Correct ad-placement is key for a higher revenue potential of your game. Before you submit, make sure that your game includes a pre-roll and mid-rolls:

Pre-roll: an ad shown before the user starts playing the game.
What you basically want to do is display the pre-roll as fast as possible to the user, so they don’t have the time to change their minds and close the game.
Best practice: placing the pre-roll on buttons in the loading/splash screen (Start, Play, Continue).

Mid-roll: an ad shown in between game sessions.
Ideally placed on all non-gameplay buttons, to spread the chance that users will see ads.
Best practice: placing the mid-rolls on each button in the Game Over/Win screen (Replay, Next, Menu).

To get the most out of your game revenue and to maintain a user friendly experience, we ask you to keep these requirements in mind when deciding on the placement of the ads:

  • Ads only display upon user input, e.g. when clicking a button
  • Ads display outside of the gameplay only, to not disrupt the game experience
  • Game audio is muted when the ad is displayed
  • The game pauses when the ad is displayed

Don’t worry about spamming users with ads by placing ad-calls on too many buttons: we regulate the ad-interval through the SDK, so users will only see an ad when the set time-frame has passed.

Example:

public class ExampleClass: MonoBehaviour {

    void Awake()
    {
        GameDistribution.OnResumeGame += OnResumeGame;
        GameDistribution.OnPauseGame += OnPauseGame;
        GameDistribution.OnPreloadRewardedVideo += OnPreloadRewardedVideo;
        GameDistribution.OnRewardedVideoSuccess += OnRewardedVideoSuccess;
        GameDistribution.OnRewardedVideoFailure += OnRewardedVideoFailure;
        GameDistribution.OnRewardGame += OnRewardGame;
    }

    public void OnResumeGame()
    {
        // RESUME MY GAME
    }

    public void OnPauseGame()
    {
        // PAUSE MY GAME
    }
    
    public void OnRewardGame()
    {
        // REWARD PLAYER HERE
    }

    public void OnRewardedVideoSuccess()
    {
        // Rewarded video succeeded/completed.;
    }

    public void OnRewardedVideoFailure()
    {
        // Rewarded video failed.;
    }

    public void OnPreloadRewardedVideo(int loaded)
    {
        // Feedback about preloading ad after called GameDistribution.Instance.PreloadRewardedAd
        // 0: SDK couldn't preload ad
        // 1: SDK preloaded ad
    }

    public void ShowAd()
    {
        GameDistribution.Instance.ShowAd();
    }

    public void ShowRewardedAd()
    {
        GameDistribution.Instance.ShowRewardedAd();
    }

    public void PreloadRewardedAd()
    {
        GameDistribution.Instance.PreloadRewardedAd();
    }
}

Best Practice for Rewarded Ads

You can use multiple ad slots for rewarded ads and give your players multiple way of gathering rewards. Samples below is very nice way of implementing this feature.

Let them watch an ad to increase their attacks!

No coin no pain? Oh, it is not. Let them gain some free coins.

Who doesn't want a second chance?

Your players can take their chances to gain some buffs!

You can give away some daily gifts to your players.