Skip to content

Wortal SDK


  • Install the Wortal SDK Unity package from GitHub.
  • Set the necessary project settings via toolbar: DigitalWill/Wortal/Set Project Settings

How to Use


API Reference

Interstitial ads can be shown at various points in the game such as a level end, restart or a timed interval in games with longer levels.

// Player reached the next level.
Wortal.Ads.ShowInterstitial(Placement.Next, "NextLevel", PauseGame, ResumeGame);

// Player paused the game.
Wortal.Ads.ShowInterstitial(Placement.Pause, "PausedGame", PauseGame, ResumeGame);

// Player opened the IAP shop.
Wortal.Ads.ShowInterstitial(Placement.Browse, "BrowseShop", PauseGame, ResumeGame);

Rewarded ads can be shown too. These are longer, optional ads that the player can earn a reward for watching. The player must be notified of the ad and give permission to show before it can be shown.

// This example shows the game flow independent of the outcome of the ad.
Wortal.Ads.ShowRewarded("BonusCoins", PauseGame, ResumeGame, DontReward, RewardPlayer);

// This example shows the game flow depending on the outcome of the ad.
Wortal.Ads.ShowRewarded("ReviveAndContinue", PauseGame, ResumeAudio, EndGame, RevivePlayerAndContinue);

NOTE: Players should only be rewarded in the AdViewed callback.


API Reference

The Analytics API can be used to track game events that can help better understand how players are interacting with the game. This data will be available for viewing in the Wortal dashboard.

// Logs the start of the level.
Wortal.Analytics.LogLevelStart("Level 3");

// Logs the end of the level. Will track the time spent playing the level if the name matches
// the name of the last logLevelStart() call.
Wortal.Analytics.LogLevelEnd("Level 3", "100", true);

// Logs a choice the player made in the game. This can be useful for balancing the game
// and seeing what content your players interact with the most.
Wortal.Analytics.LogGameChoice("Character", "Blue");


API Reference

The Context API is used to connect players and allow them to interact in the game session, share their content and send messages to each other.

// Invite a friend to play the game.
    () => Debug.Log("New context: " + Wortal.Context.GetID()),
    error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));

// Share your game activity with friends.
    shareResult => Debug.Log("Number of shares: " + shareResult),
    error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));

// Example ContextPayload
var payload = new ContextPayload
    Image = "dataURLToBase64Image",
    Text = new LocalizableContent
        Default = "Play",
        Localizations = new Dictionary<string, string>
            {"en_US", "Play"},
            {"ja_JP", "プレイ"},
    Data = new Dictionary<string, object>
        {"current_level", 1},

In-App Purchases

API Reference

The In-App Purchases (IAP) API is used to provide an interface for in-game transactions on the platforms. This process will differ based on what platform the game is being played on, but the API remains the same.

// Get the catalog of products the player can purchase.
    catalog => Debug.Log(catalog[0].Title),
    error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));

// Purchase a product.
Wortal.IAP.MakePurchase(new WortalIAP.PurchaseConfig
        ProductID = "id.code.for.product",
    purchase => Debug.Log(purchase.PurchaseToken), // Use this token to consume purchase
    error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));


API Reference

The Leaderboard API gives the game access to the platform's leaderboard functionality. This is where you can track player's scores and compare them to other players.

// Get the top 10 entries on the global leaderboard.
Wortal.Leaderboard.GetEntries("global", 10,
    entries => Debug.Log("Score: " + entries[0].Score),
    error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));

// Add the player's score to the leaderboard.
Wortal.Leaderboard.SendEntry("global", 100,
    entry => Debug.Log("Score: " + entry.Score),
    error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));


API Reference

You can find details about the current player via the Player API.

// Get a list of the player's friends who have also played this game.
    players => Debug.Log(players[0].GetName()),
    error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));

// Save the player's data to the platform
Dictionary<string, object> data = new()
    { "items", new Dictionary<string, int>
            { "coins", 100 },
            { "boosters", 2 },
    { "lives", 3 },
    () => Debug.Log("Data set"),
    error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));

// Get player's save data from the platform
Wortal.Player.GetData(new[] { "items", "lives" },
    data =>
        // Check the return values types before casting or operating on them.
        foreach (KeyValuePair<string, object> kvp in data)
            Debug.Log("Key name: " + kvp.Key);
            Debug.Log("Value type: " + kvp.Value.GetType());

        // Nested objects should de-serialize as IDictionary<string, object>
        var items = (Dictionary<string, object>)data["items"];
        Debug.Log("Coins: " + items["coins"]);
    error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));


API Reference

Details about the current session can be accessed in the Session API.

// Get the entry point of where the game started from.
    entryPoint => Debug.Log(entryPoint),
    error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));