Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

New Device Simulator (preview)

Discussion in '2019.3 Beta' started by JC-Cimetiere, Sep 26, 2019.

  1. Rafael_CS

    Rafael_CS

    Joined:
    Sep 16, 2013
    Posts:
    162
    Hello guys, thanks for this amazing package, maybe, in next releases can a toggle with "Use Aspect Ratio" instead "Fixed-Resolution" be added as new feature improvement?

    When trying to simulate devices with resolution greater than my Monitor (1080p) the text became unreadable. Changing from "Fixed-Resolution" to "Aspect-Ratio" can fix this.

    With Simulator (Fixed-Resolution)
    upload_2020-9-9_15-55-18.png

    With Game View (Aspect-Ratio)
    upload_2020-9-9_15-53-32.png
     
  2. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    51
    Greetings! Could you please submit a bug report by going to Help -> Report a Bug...?
     
  3. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    51
    Hi! I see our screen texture is suffering from a severe case of no mipmaps. Thanks for the feedback, I've noted this issue.
     
  4. ritro_hype

    ritro_hype

    Joined:
    Aug 31, 2020
    Posts:
    5
    Hello. It would be nice to somehow exclude rounded corners from some devices safe area. Say, some custom settings per application, because some interface would benefit from not excluding them but some needs too exclude them. Now android devices like huawei and samsung include rounded corners in safe area while Iphone devices have very large offset of this safe area.

    I know, that device itself is responsible for this safe area values, but we have to invent custom tools to mitigate this problem.
     
  5. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    51
    Hi! I was surprised myself that this is the case on many Android phones. I will pass this feedback to the mobile team, but I'm not sure if we can build anything robust in this case, if the phone does not give us data about rounded corners.
     
  6. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
    Hi, has there been any progress on making keyboard input works on the simulator?
     
  7. AmmarSalim

    AmmarSalim

    Joined:
    Sep 2, 2016
    Posts:
    25
    For several days now I have been searching for this addition.
    Thank you.
     
  8. CyberAngel

    CyberAngel

    Joined:
    Oct 4, 2014
    Posts:
    128
    When are devices that have been out for a good 8 months now going to be supported? Like the Samsung S20/+/Ultra
     
  9. yangskybox

    yangskybox

    Joined:
    Oct 4, 2019
    Posts:
    3
    Is there a way to detect that the simulator is active?

    Not being able to use the full gamut of Android and iOS features while running in Editor is a given. What's problematic is that there is no way reliably detect that the player is in fact running in the Editor with the simulator active when device info mocking is turned on.
     
  10. Akhrand

    Akhrand

    Joined:
    Jan 31, 2013
    Posts:
    5
    Hello!

    This Device Simulator seems amazing. I'm looking forward to use it, but I just keep getting errors when trying to make it work along with the New Input System.

    I just created the project and installed Device Simulator, working perfectly. Next, I installed the New Input System and it's when Device Simulator stops working. Nothing shown on Simulator tab and these errors appearing on the console:



    It doesn't matter what Input System I set in Player Settings either, it doesn't work


    Any idea how to fix it? Am I doing something wrong or is this a bug?

    Thanks!!
     

    Attached Files:

  11. Darkon_Who

    Darkon_Who

    Joined:
    Jul 22, 2017
    Posts:
    14
    Hey guys @JC-Cimetiere, randomly started getting issues where the device simulator has become unusable for some reason :/ Please find attached the errors its throwing, it just started happening randomly when I updated to Unity 2019.4.12 LTS 2019.4.13 LTS.

    Please find below the errors I am currently getting. Thanks in advance.

    Please note I have tried reinstalling the package to no avail.

    Screenshot 2020-10-31 082711.png Screenshot 2020-10-31 082744.png Screenshot 2020-10-31 082817.png
     
  12. GWUnity

    GWUnity

    Joined:
    Oct 14, 2020
    Posts:
    6
    The device simulator is a great time saver!

    I would like to see some kind of indicator in the device list to show which devices have cutouts or other unusual screen features. That would make it quicker to find and test such devices.

    I also noticed the Huawei P20 device has a cutout but the safe area does not adjust for it. Is that what the device actually returns?
     
  13. Darkon_Who

    Darkon_Who

    Joined:
    Jul 22, 2017
    Posts:
    14
    bump for above issues please
     
  14. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,311
    I'm getting some strange click events happening when using the device simulator.
    Button clicks are registering for UI elements even if the pointer is not contained within their RectTransform.

    Anyone else experiencing this?

    I'm using new Input system.
     
  15. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    I'm having the same issue. Device simulator is really great but now I can't use it :/
     
  16. bottledgalaxy

    bottledgalaxy

    Joined:
    Jul 19, 2019
    Posts:
    85
    Device Simulator gives out an error on Unity 2021.1:

    Library/PackageCache/com.unity.device-simulator@2.2.3-preview/Editor/SimulatorApplicationSettings.cs(33,87): error CS1061: 'ApplicationSimulation' does not contain a definition for 'OnLowMemory' and no accessible extension method 'OnLowMemory' accepting a first argument of type 'ApplicationSimulation' could be found (are you missing a using directive or an assembly reference?)
     
  17. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    51
    If the simulator does not have an orange indicator above the device that says that this simulator is not currently active, then it is simulating. The way it works is that the last focused simulator is the one currently active. Focusing a Game window will disable the simulation.
     
  18. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    51
    This is fixed in the latest version 2.2.4-preview
     
  19. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    51
    Thanks for the feedback, I've added it to our radar.

    About the Huawei P20, it didn't have cutouts and safe area on that OS version which is captured for the simulator. It does have those features in the latest OS version. We already have a bug report for that and will update the device at some point.
     
  20. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    51
    I don't believe we have a bug report for this issue, could you please submit a bug report by going to Help -> Report a bug... in the editor?
     
  21. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    51
    In 2021.1 we are putting the Device Simulator directly into the editor so the package is no longer needed. We are deprecating the package starting with 2021.1, meaning that you will no longer be able to install it.

    We will continue to maintain the package for older Unity versions.
     
    WHDTUD likes this.
  22. Tx

    Tx

    Joined:
    Jul 4, 2012
    Posts:
    108
    Sorry but isn't it funny that you do a lot to decouple features from the editor, put them in packages, then put them back in the editor and leave the packages like this?
    Too bad, I needed this feature a lot but I have no intention of moving to 2021 until it enters LTS.
    However I recommend updating the package documentation, there is no hint that it is discontinued and I came across this conversation by accident. I wanted to update a project to 2019 just to use it, now what's the point?
     
    Noisecrime likes this.
  23. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    51
    I want to clarify that the package will continue to be maintained for Unity 2019 and 2020, it's not going away on these versions.
     
    Tx likes this.
  24. Akhrand

    Akhrand

    Joined:
    Jan 31, 2013
    Posts:
    5
    That's great. THANKS! I just tested it and saw it working :)

    In the quick test I noticed two things:
    • I have to disable Simulate Touch Input from Mouse or Pen option from "Input Debug" window. Otherwise it just takes the first touch.
    • Performance seems to drop a lot. Reading previous posts I suppose it's normal at the moment.
     
  25. ByMedion

    ByMedion

    Joined:
    May 10, 2018
    Posts:
    19
    Hi! Please add iPhone 12, 12 mini, 12 pro and pro max
     
  26. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
    By maintained I think you mean just minor bug fix and not new features right?
    Otherwise I don't see the reason why not continue with it as package even in 2021.
     
    Noisecrime likes this.
  27. bottledgalaxy

    bottledgalaxy

    Joined:
    Jul 19, 2019
    Posts:
    85
    Is it there already? I could not find it...
     
  28. Ziplock9000

    Ziplock9000

    Joined:
    Jan 26, 2016
    Posts:
    360
    Is there a way to know if code is running in 'device simulator mode' versus 'game mode' within the editor?

    I need this because I need to switch which mouse/pointer/button detection code depending on which window I'm in.

    I've not as yet been able to create universal code that works for both when I'm trying to mask out UI elements.

    This works for game mode:
    Code (CSharp):
    1. if ((Input.GetMouseButtonDown(0)) && (!EventSystem.current.IsPointerOverGameObject()))
    This works for simulator mode (and mobile):
    Code (CSharp):
    1. if ((Input.touchCount == 1) && (Input.GetTouch(0).phase == TouchPhase.Began) && (!EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId)))
    If I could detect if the editor is in the game or simulator window I can just switch the set of checking code to use when I'm in the editor with UNITY_EDITOR.. Obvious the !UNITY_EDITOR would just have the mobile checking.
     
  29. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    Device simulator performance is soo slow, is there any hope for improvement?

    My team really loves the simulator for previewing UI on different screen sizes, but the input lag is so bad, that it's almost impossible to drag controls or even click buttons sometimes because the clicks are missed in frame drops. The regular scene view and game view have fps in the hundreds and are smooth.

    See this difference between the simulator and regular game view in the profiler:

    upload_2020-12-17_15-26-58.png

    The profiler looks like 30 fps but that's not even what's happening in reality. When dragging an object in the simulator it jumps around with almost a second lag in between, but in the regular game view everything is normal.
     
  30. UWSUMUT

    UWSUMUT

    Joined:
    Jul 14, 2020
    Posts:
    9
    Hey, I have some suggestions;
    Can you please add a keybinding system to emulate generic multi-touch events like pinch to zoom in/out, two-finger camera rolling?
    It would make testing small additions easier and quicker when you don't really need unity remote for touch input.
    Also you can add emulation for other inputs like gyroscope/accelerometer etc.
     
    Last edited: Dec 18, 2020
  31. danUnity

    danUnity

    Joined:
    Apr 28, 2015
    Posts:
    229
    Hi,

    I would like to be able to change the tested device by script. I want to go through every devices on the list automatically every 5 seconds instead of having to click the dropdown every time. It seems like a trivial problem but it a long time to click on every device one at a time.

    Is that already somewhere hidden in the API?
     
  32. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    51
    Thanks for reporting the issue with Simulate Touch Input from Mouse or Pen, I'll investigate what's happening there.
     
  33. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    51
    We plan to port API changes from 2021.1 version to the package version, so that the transition from one to the other is as simple as possible. Beyond that point the package will most likely receive bug fixes and new devices only.
     
  34. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    51
    You should be able to find it in the 2021.1 beta.
     
  35. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    51
    There is hope for improvement. Starting with 2021.1 this issue is fixed. As for the previous versions we will most likely add a way to disable SystemInfo and Application simulation, which are causing the slow down.
     
    Xarbrough likes this.
  36. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    51
    Thank you for your suggestions, these features are on our radar and we will definitely add them at some point. Though at this point I can't promise when exactly.
     
  37. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    51
    Thanks for the feedback. It's not currently possible to do that, but we plan to implement this feature in the future.
     
  38. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    51
    We don't have an API to detect if the simulator is active at the moment. You could try using SystemInfo.deviceType to check if the device is a handheld. It should return handheld when the Simulator is active.
     
  39. Toastbyte

    Toastbyte

    Joined:
    Sep 1, 2016
    Posts:
    54
    Hi, I cant find the device simulator in the package manager. Is the device simulator not supported in 2020.2.1f1?
     
  40. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    51
    Hi, it could be hidden, if you don't have preview packages enabled in the project. You can enable preview packages by going into Project Settings -> Package Manager and ticking the Enable Pre-release Packages box.
     
    Toastbyte likes this.
  41. Toastbyte

    Toastbyte

    Joined:
    Sep 1, 2016
    Posts:
    54
    I completely forgot about that. Thank you!!
     
  42. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    I'm confused about this section in the blog post:
    What does it mean? If we use
    Screen.width
    , will it return the wrong value on Device Simulator? Will we have to use
    UnityEngine.Device.Screen.width
    ?
     
  43. ExcaliburGames

    ExcaliburGames

    Joined:
    Oct 29, 2013
    Posts:
    50
    Hi, thanks for device simulator.
    But, how can I saw cutouts? I see only button for "Safe Area"
    And what about emulating iOS Home button ?
     
  44. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    51

    Hi!

    For Application and SystemInfo, if you want to get simulated values in the editor you do have to use classes inside UnityEngine.Device namespace. We removed simulation from existing classes to prevent unexpected behaviors and to fix performance issues that plague the package version.

    As for Screen we did leave a bit of simulation in the original UnityEngine.Screen class, so in your example
    Screen.width would actually return the proper value. However, UnityEngine.Screen might not work as well as
    UnityEngine.Device.Screen, so I recommend using UnityEngine.Device.Screen going forward.

    One example where UnityEngine.Screen.width/height will not return simulated value is from editor code, when drawing windows, while UnityEngine.Device.Screen will always return appropriate simulated values.
     
  45. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    51
    Hi!

    Device Simulator does not have a built in way to visualize cutouts. You can query cutouts through code using
    UnityEngine.Device.Screen.cutouts
    .

    We also don't support home button simulation at the moment.

    Thank you for your feedback, it really helps us decide what to work on next.
     
  46. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @RomanBanana Thank you for the prompt reply. Is there a performance difference between UnityEngine.Device functions and UnityEngine functions in a built game?
     
  47. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    51
    There should not be, we would consider it a bug if there was.
     
    yasirkula likes this.
  48. BennyKokMusic

    BennyKokMusic

    Joined:
    Dec 22, 2016
    Posts:
    33
  49. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    51
    It is no longer there. Instead of using assembly scope, we added new APIs that are always simulated when the simulator is active. These new APIs can be found in the UnityEngine.Device namespace, for example SystemInfo. You can use these APIs both in the editor and in the final build.
     
    BennyKokMusic likes this.
  50. TeohRIK

    TeohRIK

    Joined:
    Jan 22, 2014
    Posts:
    106
    Hi, wanna know is it support to simulate folding devices now?