The Device Simulator provides simulated classes, which you can use to test code that responds to device-specific behaviors in the Device Simulator.
The following simulated classes are in the UnityEngine.Device namespace:
These simulated classes have the same members as their regular UnityEngine namespace counterparts. You can use them anywhere in your codebase where you would normally use the regular classes. There is no performance impact, and you can use them in release builds.
In the Editor, when the Device Simulator is active, the simulated classes mimic the platform-specific behaviors of the simulated device; for example, Device.SystemInfo.operatingSystem returns the Android or iOS version of the simulated device.
In a built application, or when the Device Simulator isn’t active, the simulated classes have the same behavior as their counterparts in the UnityEngine namespace.
Although the simulated classes have the same members as the regular classes, the Device Simulator doesn’t simulate every behavior. In the UnityEditor, members that the Device Simulator doesn’t simulate have the same behavior as their UnityEngine equivalent, which isn’t platform-dependent. For example, the Device Simulator doesn’t simulate Device.Screen.brightness. This means this member has the same in-Editor behavior as UnityEngine.Screen.brightness, which always returns 1
. For information on which members the Device Simulator simulates, see the API documentation for:
If you want to convert existing code to use classes from the UnityEngine.Device namespace, it’s best practice to use alias directives. For example:
using Screen = UnityEngine.Device.Screen;
using Application = UnityEngine.Device.Application;
using SystemInfo = UnityEngine.Device.SystemInfo;
This way you can change which class the entire file uses and not change every API call.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.