Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

New Device Simulator (preview)

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

  1. JC-Cimetiere

    JC-Cimetiere

    Unity Technologies

    Joined:
    May 8, 2014
    Posts:
    102
    Thanks for the suggestion. We are considering this for the next iteration, although we are focusing now on getting out of preview.
    Could you share more about the use case?
     
  2. JC-Cimetiere

    JC-Cimetiere

    Unity Technologies

    Joined:
    May 8, 2014
    Posts:
    102
    We are considering, it's on our backlog but not decided yet when we will implement. So I cannot promise anything at this time.
    JC
     
  3. JC-Cimetiere

    JC-Cimetiere

    Unity Technologies

    Joined:
    May 8, 2014
    Posts:
    102
    Hi,
    thanks for the suggestion.
    Remapping various input events to custom events is a great suggestion. We are looking into this and added to the backlog. Unfortunately I cannot offer any timeline for this at the moment.
    JC
     
  4. JC-Cimetiere

    JC-Cimetiere

    Unity Technologies

    Joined:
    May 8, 2014
    Posts:
    102
    Let me also suggest a workaround since https://docs.unity3d.com/ScriptReference/iOS.DeviceGeneration.html is not simulated, you can use SystemInfo.deviceModel in your game to determine the device, it is simulated.
    And then do the mapping with Device Generations.
    You'll find below a quick mapping I did (to double check) based on info available here:
    https://gist.github.com/adamawolf/3048717#file-apple_mobile_device_types-txt
    We are looking into making it easier to deal with this!
    I hope this help.
    JC

    ----
    SystemInfo.deviceModel, Unity.iOS.DeviceGen, Friendlyname
    i386 , #N/A, iPhone Simulator
    x86_64 , #N/A, iPhone Simulator
    iPhone1,1 , iPhone, iPhone
    iPhone1,2 , iPhone3G, iPhone 3G
    iPhone2,1 , iPhone3GS, iPhone 3GS
    iPhone3,1 , iPhone4, iPhone 4
    iPhone3,2 , iPhone4, iPhone 4 GSM Rev A
    iPhone3,3 , iPhone4, iPhone 4 CDMA
    iPhone4,1 , iPhone4S, iPhone 4S
    iPhone5,1 , iPhone5, iPhone 5 (GSM)
    iPhone5,2 , iPhone5, iPhone 5 (GSM+CDMA)
    iPhone5,3 , iPhone5C, iPhone 5C (GSM)
    iPhone5,4 , iPhone5C, iPhone 5C (Global)
    iPhone6,1 , iPhone5S, iPhone 5S (GSM)
    iPhone6,2 , iPhone5S, iPhone 5S (Global)
    iPhone7,1 , iPhone6Plus, iPhone 6 Plus
    iPhone7,2 , iPhone6, iPhone 6
    iPhone8,1 , iPhone6S, iPhone 6s
    iPhone8,2 , iPhone6SPlus, iPhone 6s Plus
    iPhone8,4 , iPhoneSE1Gen, iPhone SE (GSM)
    iPhone9,1 , iPhone7, iPhone 7
    iPhone9,2 , iPhone7Plus, iPhone 7 Plus
    iPhone9,3 , iPhone7, iPhone 7
    iPhone9,4 , iPhone7Plus, iPhone 7 Plus
    iPhone10,1 , iPhone8, iPhone 8
    iPhone10,2 , iPhone8Plus, iPhone 8 Plus
    iPhone10,3 , iPhoneX, iPhone X Global
    iPhone10,4 , iPhone8, iPhone 8
    iPhone10,5 , iPhone8Plus, iPhone 8 Plus
    iPhone10,6 , iPhoneX, iPhone X GSM
    iPhone11,2 , iPhoneXS, iPhone XS
    iPhone11,4 , iPhoneXSMax, iPhone XS Max
    iPhone11,6 , iPhoneXS, iPhone XS Max Global
    iPhone11,8 , iPhoneXR, iPhone XR
    iPhone12,1 , iPhone11, iPhone 11
    iPhone12,3 , iPhone11Pro, iPhone 11 Pro
    iPhone12,5 , iPhone11ProMax, iPhone 11 Pro Max
     
    MassiveTchnologies and ferretnt like this.
  5. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    853
    @JC-Cimetiere The language dropdown still gets reset to English as soon as Play starts. Any info on when that might be fixed?
     
    Last edited: Apr 30, 2020
  6. MassiveTchnologies

    MassiveTchnologies

    Joined:
    Jul 5, 2016
    Posts:
    56
    Thanks! We ended up going with this approach for now, although it's more difficult to maintain. We have a lot of logic in the app that changes between iPhone / iPad and between iPhone models (notch, no notch, low end device, low res screen, etc)

     
  7. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    24
    Hi, I can't promise an exact date, but we are aware of this issue and will be fixing it in the coming months
     
    luispedrofonseca likes this.
  8. cg-adam

    cg-adam

    Joined:
    Jul 30, 2019
    Posts:
    44
    On 2019.3.13f1 using the Devil Simulator package 2.2.2, the Screen class is not updating the screen size correctly. It reports the size correctly when entering a scene, but upon changing the simulation device and then testing again, the screen size is being reported wrong always (even when switching back to the original device). I have tried this inside the default assembly and a custom assembly with the same issue in both.
     
  9. bottledgalaxy

    bottledgalaxy

    Joined:
    Jul 19, 2019
    Posts:
    28
    Is this not available in Unity 2020.1? Can't find it in the Package Manager
     
  10. cg-adam

    cg-adam

    Joined:
    Jul 30, 2019
    Posts:
    44
    If the simulator window loses focus (i.e. you push a button in the inspector) then the Screen API reports back the wrong width and height. This is quite frustrating when using custom editor buttons (Odin) to run layout routines which rely on screen size data.
     
  11. Sascha2

    Sascha2

    Joined:
    Nov 1, 2017
    Posts:
    10
    Great tool, thanks! Also hoping for full input support. I use the scroll wheel to simulate pinch-to-zoom and ESC to simulate the back button - both don't work at the moment.
     
    PacoLabs likes this.
  12. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    664
    @bottledgalaxy 2020.1 made it way harder to enable Preview packages, you need to do that in Project Settings now, then you can install it.

    @JC-Cimetiere turns out that all Mice are completely disabled when using the Device Simulator window (with a comment saying "rene suggested it" ;)). However, both Android and iOS have full mouse and keyboard support, with iPadOS heavily pivoting in a direction of encouraging all apps to support that. Can you please make that optional? Otherwise it's impossible to use Device Simulator to simulate an iPad with mouse input.

    (Additionally, the way you do that is buggy - as soon as Device Simulation is opened once, mouse input is broken everywhere else (e.g. Game View) even when DeviceSim is not in focus or not active at all. I think globally disabling Mouse Input is not a good idea.)
     
    Last edited: Jun 8, 2020
  13. marwi

    marwi

    Joined:
    Aug 13, 2014
    Posts:
    104
    Got to project settings and enable "show preview packages"
     
  14. bottledgalaxy

    bottledgalaxy

    Joined:
    Jul 19, 2019
    Posts:
    28
    marwi likes this.
  15. _Adriaan

    _Adriaan

    Joined:
    Nov 12, 2009
    Posts:
    463
    Can the Device Simulator also apply things like Screen.safeArea when not in Play mode? It would be more than convenient to preview the interface with safe areas applied while designing the interface.
     
  16. Suduckgames

    Suduckgames

    Joined:
    Nov 28, 2016
    Posts:
    197
    I have the same issue. I think that it reports the size of the layout instead of the phone. A workaround is to exit/enter play mode but for testing purposes it take a lot of time
     
  17. AntLewis

    AntLewis

    Joined:
    Feb 2, 2010
    Posts:
    202
    Hey, would you mind clarifying something - does Device Simluator 'only' illustrate the safe area/notches or does it also provide functionality to adapt your UI based on these values? For example I intended to create a parent gameobject that read in the safe area then adjusted it's rect transform so I can guarantee all child objects are within - or does Device Similator do something similar? Cheers
     
  18. cg-adam

    cg-adam

    Joined:
    Jul 30, 2019
    Posts:
    44
    I reported a bug and the dev team are working on a fix. In short the issue is when the simulator view loses focus it reports the wrong values.
     
  19. Noisecrime

    Noisecrime

    Joined:
    Apr 7, 2010
    Posts:
    1,566
    Really like the Device Simulator and its potential to both speed up and ease development for mobile.

    I've found a bug in version 2.2.2 and 2019.4, where by rotating some devices fails to change the orientation. It may well be related to this report early in the thread ( link ).

    Basically if i have say iPhone X selected, with auto-rotation enabled and then cycle through the rotations using the toolbar buttons, everyone works except 'Portrait upside down'. The ScreenSettings Orientation value doesn't change to 'upside down' and instead stays on whatever the previous value was ( i.e. left or right ). Yet the device rendered on the screen does rotate ( between landscape to portrait ) but it retains the alignment from the previous orientation ( again either left or right ).

    This behavior does not occur on all devices and i'm not sure how many or which ones are affected, just that I noticed that the iPhoneX happens to be affected.

    EDIT - I think I may have found the source of the problem.
    Looking at the json device definitions in the package I can see for iPhoneX that its missing Orientation 2 completely. Somewhat surprised it doesn't break the simulator completely.
    Same issue found in
    • Apple iPhone XR.device.json
    • Apple iPhone XS Max.device.json
    • Apple iPhone XS.device.json
    • Apple iPhone 11.device.json
    Looks like you need some validation tool to run over all the json data to catch these issues.
     
    Last edited: Jun 20, 2020
  20. mogmet

    mogmet

    Joined:
    May 19, 2020
    Posts:
    1
    When I open the game view with Device Simulator installed, I get a lot of errors like the following and cannot open the game view.
    What is the solution?

    unity version: 2019.4.1.f1
    Device Simulator version: 2.2.2

    Code (CSharp):
    1. ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    2. Parameter name: index
    3. System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <fb001e01371b4adca20013e0ac763896>:0)
    4. System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <fb001e01371b4adca20013e0ac763896>:0)
    5. System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <fb001e01371b4adca20013e0ac763896>:0)
    6. UnityEditor.GameView.DoToolbarGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/GameView/GameView.cs:498)
    7. UnityEditor.GameView.OnGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/GameView/GameView.cs:801)
    8. System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <fb001e01371b4adca20013e0ac763896>:0)
    9. Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    10. System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <fb001e01371b4adca20013e0ac763896>:0)
    11. System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <fb001e01371b4adca20013e0ac763896>:0)
    12. UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:381)
    13. UnityEditor.HostView.Invoke (System.String methodName) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:375)
    14. UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:351)
    15. UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:406)
    16. UnityEditor.DockArea.OldOnGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:395)
    17. UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:276)
    18. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) (at /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:197)
     
  21. DreamPower

    DreamPower

    Joined:
    Apr 2, 2017
    Posts:
    86
    Hi, the documentation says that Unity Remote is going to be deprecated in Unity 2020.1, with the Device Simulator recommended as a replacement. So is the Device Simulator getting support for things like multitouch or gyroscope orientation, which cannot otherwise be tested in the current Unity Editor, in Unity 2020.1?
     
    kodagames, ferretnt and fherbst like this.
  22. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    24
    Hi, this is actually intended behavior for these devices, because they do not support Portrait Upside Down, in other words you would get the same behavior on a real device.

    That said, we do have a few Android devices that support Portrait Upside Down in real life, but don't support in in the simulator.
     
    Noisecrime likes this.
  23. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    24
    Device Simulator does not have any helper functions to restrict content to the safe area. It does however make Screen.safeArea return appropriate values for the simulated device, so you can validate your solution for handling the safe area inside the editor.
     
  24. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    24
    Hi, it already does that. At least simulated device Screen.safeArea is returned in edit mode.

    This is a guess on my part, but it could be that the code that you are using to adjust things based on the safe area does not run in edit mode.
     
  25. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    24
    Hi, thanks for the criticism, I can absolutely see how the current behavior is causing issues. We will look into this.
     
    Noisecrime and fherbst like this.
  26. marwi

    marwi

    Joined:
    Aug 13, 2014
    Posts:
    104
    Two suggestions:

    1) Add option to render scene camera e.g. when editing UI prefabs it would help greatly if I could see that being rendered in device simulator directly
    2) Add option to render device preview size close to "real world" size - e.g. try to display the ipad on screen at the same size as the physical ipad would be - if dpi is an issue: add option to enter my screen dpi
     
  27. kodagames

    kodagames

    Joined:
    Jul 8, 2009
    Posts:
    537
    Is there a way to create more real estate on the left hand side of the window (possibly a drop down, instead of so much space being used), when I’m developing once I select a setting I only need to see the screen of the phone and not the options anymore.

    Thanks for hearing my suggestion. Keep up the great work!
     
    fherbst likes this.
  28. Noisecrime

    Noisecrime

    Joined:
    Apr 7, 2010
    Posts:
    1,566
    Wow, I had no idea, thanks for the heads up. I guess its kind of logical they would want to prevent portrait upside down when phones have all these different notches nowadays, though it does seem to be taking control away from the user.

    May I suggest that perhaps you can add an onscreen popup alert/warning in the simulator to the affect that its not supported? It would prevent more reports of a bug from people like myself who haven't yet encountered these devices that actively prevent specific orientations.

    Its been some time since I looked at this, but I wonder if the behavior should still retain the rotation, but be presented upsidedown ( i.e. view is locked to phone so it looks like what you would see on the device, but is now upsidedown in the simualtor ). This might be what you mean in your reply, but from memory I seem to remember the popup for selecting orientation got confused as the entry in the json definitions didn't exist. I'm just thinking about whether automated testing or general testing in the simulator might get messed up as that orientation option doesn't exist in the data.
     
  29. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    24
    I want to make sure that I understand what you are trying to achieve. Is your goal to edit the UI directly in the simulator so you can see what is happening?


    This is something that has been requested multiple times and while I can't give any promises at the moment, this is something we are definitely considering.
     
  30. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    24
    Yes! You can hide the options panel by clicking the little arrow button to the left of the Scale slider.
     
    fherbst likes this.
  31. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    24
    Something should be done about this, I believe this "issue" was reported by every single QA that tested Device Simulator.

    In the current device file format missing orientation means that that orientation is not supported on this device.
     
  32. kodagames

    kodagames

    Joined:
    Jul 8, 2009
    Posts:
    537
    Awesome Thank you very much!!!
     
  33. marwi

    marwi

    Joined:
    Aug 13, 2014
    Posts:
    104
    I dont need to edit the UI in the simulator, previewing my UI while in edit mode would be already enough (e.g. when I'm working on an UI element in prefab mode)
    that would be a great addition, thanks
     
  34. unity-huunity

    unity-huunity

    Joined:
    Dec 17, 2013
    Posts:
    10
    hey, thank you for that feature. is there any way to switch to next/priv device by hot key?
     
  35. tyler_unity846

    tyler_unity846

    Joined:
    Apr 22, 2020
    Posts:
    2
    Really enjoying the device simulator.
    One issue I am having though is that when I hit the play button and run the scene the simulator resolution is reduced for that device. For example, on Apple iPhone X, resolution in portrait mode is 1125x2436. However, when I hit the play button this reduces to 600x1174.
    The values returned from Screen.safeArea are: (x:0.00, y:54.00, width:600.00, height:1174.00).
    Is there something I am missing or is there some way a script might be altering what the set resolution is for the device?
    upload_2020-8-6_18-38-30.png

    *Update: Turns out a legacy component was attached to a scene object that altered the screen resolution to a percent of what it was. Tool seems to be working well now.
     
    Last edited: Aug 9, 2020
  36. GameHourStudio

    GameHourStudio

    Joined:
    Apr 17, 2020
    Posts:
    32
    Hi, So this device simulator can not be used to model physical characteristics to test PERFORMANCE of the game in editor. Am I right or missing something? I have to make test builds many times in order to optimize various aspects of the game.

    Also can this be used to show test ads without making a build? By testing ads I mean to show real ad opening to check how banner size, or rewarded ads etc would look like and not just the Debug.log messages during testing ads.

    Thanks.
     
    Last edited: Aug 11, 2020
  37. DeathPro

    DeathPro

    Joined:
    Jul 28, 2018
    Posts:
    3
    When I am at play mode and game window (Maximize) on, I tried to change Game View to Simulator View. Nothing happens but fps went down to 10-12. When I stop and enter play mode again in Game View, fps still so low. When I close the project and reopen it, FPS is going okay while in Game View.

    While Game View is maximized, If I try to change to Simulator window, It's not changing.
    And on Simulator window, I don't know why but FPS locked to 30. Is it possible to make FPS max rate to 60 on Simulator Window? When I change to Game View after stop the play mode, It becomes normal like 100-120 FPS.

    OS: macOS Catalina 10.15.6
    Unity Version: 2019.4.5.f1
    Device Simulator Version: 2.2.3 - preview
    Universal Render Pipeline Version: 7.4.1
    Color Space: Linear
    Build Settings Platform: Android
     
    Last edited: Aug 8, 2020
  38. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    664
    Be aware that device simulator simulates device resolutions in pixel. We had performance issues on older Mac devices because they weren't able to handle the high resolutions (usually MUCH higher than your game view res).
     
  39. Masea1

    Masea1

    Joined:
    Jun 9, 2018
    Posts:
    24
    Apparently, this is not compatible with the new Input System. Any news about this?
     
  40. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    886
    @RomanBanana
    Hello guys, could you enable keyboard input in the device simulator?
    I use the keyboard to simulate some accelerometer action, and to manually trigger some events for debugging purpose but I cannot use them in the simulator because it seem keyboard input is filtered out?
     
  41. JamesA24

    JamesA24

    Joined:
    Sep 6, 2018
    Posts:
    17
    Hey guys!
    Wanted to chime in with some feedback on the package.

    If you try to simulate an Android or IOS device, you're going to encounter problems if you're using SDKs.
    For example, a project I'm working on uses GPGS and so there's code like...


    Code (CSharp):
    1.             var androidJC = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
    2.             var activity = androidJC.GetStatic<AndroidJavaObject>("currentActivity");
    Basically for actual android development, the simulator doesn't do anything because of problems like this.
    It seems to be that when you simulator Android for example, it runs the game as if UNITY_ANDROID were try and not UNITY_EDITOR. I imagine this was done intentionally, but things like SDKs, plugins, etc weren't taken into account. So it comes off to me as some kind of mistake.
     
  42. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    24
    Hi, device simulator does not simulate the performance of the device.

    Device simulator does not have integration with ads at the moment. Thanks for telling us that it would be a useful feature for you.
     
    GameHourStudio likes this.
  43. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    24
    Hi, we added the new input system support in device simulator version 2.2.0-preview.
     
  44. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    24
    This looks like a bug, I'll see what can be done.
     
  45. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    24
    Hi, thank you for your feedback.

    This is an area that we don't currently support in the simulator, android or iOS plugins would not work in editor at the moment.
     
  46. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    24
    Hi, this might be a bug, could you submit a bug report?
     
  47. RomanBanana

    RomanBanana

    Unity Technologies

    Joined:
    Jun 23, 2015
    Posts:
    24
    Hi, not at the moment. Thank you for your feedback!
     
  48. rpgw

    rpgw

    Joined:
    Jul 3, 2012
    Posts:
    45
    Installing this helped me fix a persistent issue in minutes. Cheers!
     
  49. craftercis

    craftercis

    Joined:
    Nov 27, 2017
    Posts:
    4
    Hello! Did anyone create an OnePlus 8 Pro template already?
     
  50. tiagotrigger

    tiagotrigger

    Joined:
    Mar 24, 2015
    Posts:
    2
    Can anybody confirm if this works with "Canvas: Screen Space - Camera" and Canvas Scaler "Scale With Screen Size".

    It is not working for me, as you can see in the screenshot the anchors for the Wooden Panel are [0, 1] for X and Y. But the image transcends and hides parts of it.

    And it works for Screen Space - Overlay, but not for Camera (which I need).

    This does not happen on a real device.



    Don't mind the SafeAreaController that is there, it is empty and does nothing because I found this problem just when I was about to write some code for fixing the screen safe area for my game.

    Oh, and another problem is that for whatever reason when moving the mouse inside editor or simulator window the screen flickers a lot, changing between what should be the correct positions and the wrong positions (above screenshot). And this does not happen when using Screen Space - Overlay. That is why I'm asking if the simulator was supposed to work with Canvas Screen Space - Camera.
     
    Last edited: Sep 9, 2020
unityunity