Skip to main content

Editor testing

For testing purposes, you can create custom mock implementations of some of the interfaces used by the PlayPadCommunicator component to simulate various scenarios. This allows you to thoroughly test and validate the behavior of your game without relying on actual external dependencies and running in it PlayPad, which allows for faster iteration and automated testing.

To do this, find the PlayPadCommunicator component on your scene (usually on the PlayPadCommunicator game object created from the prefab with the same name) and provide your own implementations for the communicators you want to test by adding references to your own components that implement the appropriate interfaces in the inspector. Instead of implementing the interface directly, your custom implementation has to derive from the appropriate abstract class for the given interface. This limitation comes from the fact that Unity can't serialize fields referencing interfaces. For each communicator there is an abstract class which derives from MonoBehaviour and implements the communicator interface through abstract members, which you have to override. The name of such class always follows the pattern CustomStandalone<CommunicatorName>CommunicatorBase, for example to provide a custom implementation of the IExternalUiCommunicator interface used by the PlayPadCommunicator.ExternalUiCommunicator field, you have to create a component that derives from the CustomStandaloneExternalUiCommunicatorBase abstract class and make the PlayPadCommunicator.customExternalUiCommunicator field reference that component's instance.

tip

If you want to find out how default Editor implementations for some communicators work, search for their Standalone counterparts (e.g. StandaloneExternalAuthenticator).

PlayPadCommunicator inspector

Another useful tool for testing in the Editor are Scriptable Objects called Standalone Configs, which can also be set in the editor of the PlayPadCommunicator component. They provide a simple way to set constant values to be returned by matching communicator interfaces.