Skip to main content

Editor testing

For testing purposes, you can create custom mock implementations of communicator interfaces used by the PlayPadCommunicator component. This allows you to test and validate game behavior without relying on external dependencies or running in PlayPad, enabling faster iteration and automated testing.

Mock configuration

Mock communicators are managed through the PlayPadMockConfiguration ScriptableObject, which provides a centralized location for all mock settings.

Creating a mock configuration

  1. In the Project window, right-click and select Create > Elympics > PlayPadMockConfiguration.
  2. Name the asset (e.g., PlayPadMockConfiguration).

Enabling mock configuration

  1. Select the PlayPadCommunicator GameObject in your scene.
  2. In the Inspector, enable the Use Mock Configuration toggle.
  3. Assign your PlayPadMockConfiguration asset to the Mock Configuration field.

PlayPadCommunicator mock configuration

Configuring mock communicators

Open the PlayPadMockConfiguration asset to configure individual mock communicators. Each communicator has two fields:

  • Object field - reference to your custom mock component
  • Use Mock toggle - enables the mock for that specific communicator

PlayPadMockConfiguration inspector

Creating custom mock implementations

To create a custom mock communicator:

  1. Create a new MonoBehaviour script that derives from the appropriate base class.
  2. Implement all abstract members with your mock logic.
  3. Add the component to a GameObject in your scene.
  4. Attach all created scripts to that GameObject.
  5. Make a prefab out of that GameObject.
  6. Reference this GameObject in your PlayPadMockConfiguration asset.
  7. Enable the corresponding Use Mock toggle.

Example

using Cysharp.Threading.Tasks;
using ElympicsPlayPad.ExternalCommunicators.Ui;

public class MyMockExternalUiCommunicator : CustomStandaloneExternalUiCommunicatorBase
{
public override UniTask ShowLeaderboard()
{
Debug.Log("Mock: ShowLeaderboard called");
return UniTask.CompletedTask;
}

// Implement other abstract members...
}
info

Mock communicators only work in the Unity Editor or builds with the ELYMPICS_DISABLE_PLAYPAD scripting define symbol. They are automatically disabled in production WebGL builds running on PlayPad.