Tutorials
/
December 20, 2024

PlayPad - Simplifying Web3 Integration and Unity Testing

Let's see how PlayPad simplifies game creation process

The complexity of integrating Web3 features into games can seem like a daunting challenge without the right tools. From repetitive configurations to manual updates for each project, the entire process is often inefficient and prone to errors made along the way. This state of things, however, can quickly change thanks to PlayPad, a solution designed to offload Web3 integration responsibilities from the game itself, ensuring scalability, streamlined updates, and future-proofing for developers.

This article dives into the benefits of introducing PlayPad, the challenges associated with testing Web3 integration, and how to simulate PlayPad behaviors directly in the Unity Editor for seamless development and testing.

What is PlayPad?

PlayPad is a platform tailored to hosting WebGL builds and managing Web3 features, alleviating developers from handling these integrations within their games separately. Imagine creating a few games and having to manually update each and every one of them separately. This doesn’t sound exciting, right? With PlayPad, developers can streamline game updates, ensure compatibility with new features, and connect their games to broader communities via the Elympics ecosystem.

Key Benefits

  • Centralized Web3 Integration: PlayPad takes on the responsibility of Web3 functionality, freeing developers from redundant tasks that may lead to making otherwise avoidable mistakes.
  • Future-Proofing: Set up your game once, and benefit from future PlayPad updates without the need to rebuild or redeploy.
  • Efficient Communication: PlayPad delivers real-time data to your game without manual data fetching or tracking.
  • Cross-Platform Support: Works seamlessly across desktop and mobile.
  • Community Connectivity: Integrates with Telegram and the Elympics ecosystem as a built-in feature, allowing games to reach broader audiences through platforms like Elympics Cockpit and Elympics Telegram Bot.

Challenges

While PlayPad offers a number of advantages, it comes with a small caveat, testing Web3 integration requires deploying WebGL builds. For developers who are used to quick iteration loops within the Unity Editor, this can slow down the development process.

How to Use PlayPad

Using PlayPad to make Web3 integration for your game more efficient is a straightforward process, designed to simplify hosting and improve the flow of the development process. Here’s how you can get started:

Prepare Your Builds
To utilize PlayPad, you need to upload both your client and server builds. For client builds, you can use a provided upload script. This requires an access key (e.g., awesome-game.json), obtainable by contacting the Elympics Developers Discord channel. Once your builds are ready, run the upload.sh script to transfer your files to PlayPad hosting. For best practices, use versioning for builds to avoid caching issues when re-uploading files.

Select Your Hosting Environment

Deployment and Access
Once your game is developed and tested, PlayPad provides a personalized hosting solution. You’ll receive:

  • Your unique domain for hosting the game, such as https://solitaire-21.elympics.host.
  • A dedicated Telegram Bot, enabling you to publish updates and engage directly with the gaming community through integrated communication tools.

Testing PlayPad in Unity Editor

To address the challenge of WebGL build dependency for testing, the PlayPad SDK provides tools for simulating PlayPad behaviors directly in the Unity Editor. This allows developers to test features without deploying to the web.

The PlayPadCommunicator

The PlayPadCommunicator script, attached to a prefab of the same name, is the core utility for simulating PlayPad interactions. To use it, ensure you start your game from the lobby scene, as playing directly from a gameplay scene may bypass essential setup processes.

StandaloneConfigs: Mocking PlayPad Data

Standalone configurations simulate PlayPad data in the Unity Editor. These configurations are implemented as Scriptable Objects and mimic real PlayPad data flows. Note that changes to these objects during runtime won’t affect the game until it is restarted.

Key Configurations

  1. StandaloneExternalAuthenticatorConfig
    This configuration determines which features are enabled for your game and selects the connection region. The “Everything” setting is recommended for maximum feature coverage of available functions. “Capabilities” can be ignored for now.
  1. StandaloneTournamentConfig
    Contains tournament details like prize pool, tournament name and time scope used to populate the menu UI.
  1. StandaloneGameStatusConfig
    Controls the state of the Play button within the game’s UI.

Customizing PlayPad Simulation with StandaloneCommunicators

Games communicate with PlayPad using interfaces. In WebGL builds, production implementations handle this communication. In the Unity Editor, however, these interactions are simulated using StandaloneCommunicators.

While the default StandaloneCommunicators are more than sufficient for basic testing, developers can create custom communicators for their specific needs. For that, the developer should derive from CustomStandaloneCommunicators to build tailored implementations and attach them to the PlayPadCommunicator prefab via the Unity Inspector.

Example: Custom Leaderboard Simulation

The default LeaderboardCommunicator implementation offers limited functionality, such as displaying a single leaderboard entry, without updating between matches. To test a more comprehensive leaderboard UI, you can create a custom communicator:

<pre><code>

using Cysharp.Threading.Tasks;

using ElympicsPlayPad.ExternalCommunicators.Leaderboard;

using ElympicsPlayPad.Leaderboard;

using System;

using System.Threading;

public class FilledLeaderboardCommunicator : CustomStandaloneLeaderboardCommunicatorBase

{

   private const int Participants = 6;

   private const int PlayersPlacement = 3;

   public override UserHighScoreInfo? UserHighScore => _userHighScore;

   public override LeaderboardStatusInfo? Leaderboard => _leaderboard;

   private LeaderboardStatusInfo? _leaderboard;

   private UserHighScoreInfo? _userHighScore;

   public override event Action<LeaderboardStatusInfo> LeaderboardUpdated;

   public override event Action<UserHighScoreInfo> UserHighScoreUpdated;

   public override UniTask<LeaderboardStatusInfo> FetchLeaderboard(CancellationToken ct = default)

   {

       Placement[] placements = new Placement[Participants];

       for (int i = 0; i < Participants; i++)

       {

           Placement entry;

           if (i + 1 == PlayersPlacement)

               entry = new Placement

               {

                   UserId = ElympicsLobbyClient.Instance.AuthData.UserId.ToString(),

                   Nickname = ElympicsLobbyClient.Instance.AuthData.Nickname.ToString(),

                   Position = i + 1 <= 3 ? i + 1 : 2 * i + 1,

                   Score = 100 - 5 * i,

                   ScoredAt = DateTime.UtcNow.ToString("o"),

                   MatchId = "00000000-0000-0000-0001-000000000000",

                   TournamentId = "abcdef"

               };

           else

               entry = new Placement

               {

                   UserId = i.ToString(),

                   Nickname = i.ToString(),

                   Position = i + 1 <= 3 ? i + 1 : 2 * i + 1,

                   Score = 100 - 5 * i,

                   ScoredAt = DateTime.UtcNow.ToString("o"),

                   MatchId = "00000000-0000-0000-0001-000000000000",

                   TournamentId = "abcdef"

               };

           placements[i] = entry;

       }

       _leaderboard = new LeaderboardStatusInfo()

       {

           Participants = Participants,

           UserPlacement = placements[PlayersPlacement - 1],

           Placements = placements

       };

       return UniTask.FromResult(Leaderboard.Value);

   }

   public override UniTask<UserHighScoreInfo?> FetchUserHighScore(CancellationToken ct = default)

   {

       _userHighScore = new UserHighScoreInfo()

       {

           Points = 200,

           ScoredAt = DateTime.Now - TimeSpan.FromDays(7)

       };

       return UniTask.FromResult(UserHighScore);

   }

}

</code></pre>

This custom communicator simulates a fully populated leaderboard, including the results of the current player and non-consecutive placements. It enables developers to test leaderboard UIs without deploying builds.

Beyond leaderboards, developers can extend simulation capabilities to include tournaments, game status, and even PlayPad-provided modals. By deriving from classes like CustomStandaloneTournamentCommunicatorBase or CustomStandaloneGameStatusCommunicatorBase, you can manage dynamic changes during runtime.

For example, you could simulate:

  • Switching tournaments on-the-fly
  • Injecting custom modals using CustomStandaloneExternalUiCommunicatorBase
  • A small local database and simulating gathering results from played matches, updating the leaderboard at runtime

Looking Ahead

Elympics is actively working to further streamline PlayPad testing within the Unity Editor. Future updates will allow PlayPad to be hosted locally, enabling even more comprehensive and efficient testing workflows.

Conclusion

Simulating PlayPad behaviors in the Unity Editor empowers developers to test Web3 integrations without the repetitive overhead of WebGL builds. With tools like StandaloneConfigs and customizable communicators, you can now replicate real-world scenarios and refine your game more efficiently.

As PlayPad continues to evolve, developers can look forward to even more robust testing capabilities, making sure that their games deliver seamless Web3 experiences while maintaining the creative freedom that defines exceptional game development.

Join our newsletter

Real news, no spam - promise✌️