When you’re creating content for mobile devices, you have to test and tweak your project to make sure it works with a huge variety of device characteristics. Even if you have access to all of your targeted hardware, getting a sense of how your content will look on each of these devices is time-consuming.

That’s why we created a new Device Simulator, which enables you to preview the behaviors and physical characteristics of different devices. This allows game code run in the Editor to match what runs on a real device much more closely. You can now preview specific resolutions and notch/cutout layouts in the Game View, as well as preview device-specific customizations such as selected quality settings based on device info like RAM, chipset, etc.

Overview of the Device Simulator

The Device Simulator includes the following features:

An extended Game View, which allows you to turn Simulation Mode on and off and to select devices

An extensible device database that stores the device and phone configurations and characteristics that will drive API shims’ return values

API shims that return device-specific API’s results (screen resolution, device model, orientation, etc.) when used in Editor Play Mode

You can watch a demo of the Device Simulator in action.

List of simulated devices

The Device Simulator includes a list of predefined phones that are in the package by default (in the com.unity.device-simulator/com.unity.device-simulator folder). Device definitions are stored in JSON files, and we will expand this list regularly through package updates. We will also offer a mechanism for adding custom device definitions to a project so it can be shared easily and checked-in in source control.

Simulation scenarios

The two main classes that are managed by the Device Simulator are UnityEngine.Screen and UnityEngine.SystemInfo, and returned values are fed by the device definition JSON file.

This feature enables you to test in-Editor behavior that is specific to devices. For example, you can dynamically adjust your UI by calculating the size of your canvas to account for the notch on different phones.

Device Simulator showing SafeArea position and behavior to control Canvas position.

The Devices Simulator is also extensible, allowing you to build your own simulation scenarios. You can use the extension point to bring Adaptive Performance to the Simulator. This feature lets you force (simulate) throttling events, then validate your code to adjust performance on the fly and ensure that it triggers properly. We will follow up soon with a dedicated blog post explaining how extensibility works.

Simulating an Adaptive Performance throttling event to test the performance adjustment logic (here, to reduce the number of spawned objects).

A Preview version of the Device Simulator is available for Unity 2019.3 (beta) now through the Package Manager. Please join us on the forum to ask questions or share your feedback. We’re eager to hear what you think!