Search Unity

Bug Device Simulator bug

Discussion in 'Editor & General Support' started by TheSilverHand, Dec 3, 2021.

  1. TheSilverHand

    TheSilverHand

    Joined:
    Jan 29, 2021
    Posts:
    16
    Hi.My unity version is 2021.1.28f1.I'm developing a mobile game. The problem is , when I use the device simulator, I cannot get the touch position as world position. On the logs it always shows (0,0,0).But when i use 2020.3.21f1 version it's working with any error.So am i doing something wrong or there is bug in 2021 versions for device simulators ? here is the script.
    Code (CSharp):
    1.  if(Touchscreen.current.primaryTouch.press.isPressed)
    2.         {
    3.             Vector2 touchPosition = Touchscreen.current.primaryTouch.position.ReadValue();
    4.  
    5.          
    6.  
    7.             Vector3 worldPosition = mainCamera.ScreenToWorldPoint(touchPosition);
    8.  
    9.             Debug.Log(worldPosition);
    10.         }
    11.