Search Unity

Device Simulator not detecting handheld

Discussion in 'Editor & General Support' started by wuannetraam, Jun 30, 2021.

  1. wuannetraam

    wuannetraam

    Joined:
    Oct 29, 2019
    Posts:
    87
    So I have activated Device Simulator in Unity 2021.2 and this is the script I have added to my scene:


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class DeviceCheck : MonoBehaviour
    6. {
    7.     public Camera myCamera;
    8.     public GameObject map;
    9.  
    10.     // Start is called before the first frame update
    11.     void Start()
    12.     {
    13.      
    14.  
    15.     }
    16.  
    17.     // Update is called once per frame
    18.     void Update()
    19.     {
    20.  
    21.         //Check if the device running this is a desktop
    22.         if (SystemInfo.deviceType == DeviceType.Desktop)
    23.         {
    24.             Debug.Log("Desktop");
    25.             myCamera.fieldOfView = 53;
    26.             map.transform.localScale += new Vector3(0f, 0f, 0f);
    27.         }
    28.  
    29.         //Check if the device running this is a handheld
    30.         if (SystemInfo.deviceType == DeviceType.Handheld)
    31.         {
    32.             Debug.Log("Mobile");
    33.             myCamera.fieldOfView = 40;
    34.             map.transform.localScale += new Vector3(6f, 6f, 6f);
    35.         }
    36.  
    37.     }
    38. }
    39.  
    I would think that it should print "Mobile" when I am in simulator mode. But it keeps saying "Desktop".
    Anyone who can help me out with this?

    Best,
    Maarten
     
  2. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    3,144
    I just opened a blank project, downloaded the Device Simulator package, put this

    Code (csharp):
    1.  
    2. void Start()
    3.     {
    4.         Debug.Log(SystemInfo.deviceType);
    5.     }
    6.  
    in a script, attached it to the main camera, changed my Game mode to Simulator, and it showed this (see bottom left corner):
    handheld.png
     
  3. wuannetraam

    wuannetraam

    Joined:
    Oct 29, 2019
    Posts:
    87
    What Unity version are you on?
     
  4. wuannetraam

    wuannetraam

    Joined:
    Oct 29, 2019
    Posts:
    87
    Ok so I think this is a bug in Unity 2021.2.0.a21.2949.
    The console shows "Desktop".
    I've done the same in Unity 2019.4.9f1 and it shows "Handheld" like it should.
     
  5. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    3,144
    That was in 2020.3.12f1.

    Edit: I just tried in 2021.1.12f1 and got the same outcome as you:
    Unity_2021-07-01_09-33-57.png
    (also using Windows snip with Unity running in Device Simulator mode apparently crashes my display driver and forces me to hard reboot, losing a running blender mesh render and a running scientific sim, which is always fun)
     
    Last edited: Jul 1, 2021
  6. wuannetraam

    wuannetraam

    Joined:
    Oct 29, 2019
    Posts:
    87
    that is always fun. lolllll. Hope you have everything back. I have submitted this bug to Unity.
     
    EternalAmbiguity likes this.