Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Input Update extremely slow when Mousing over Window

Discussion in 'Input System' started by Thygrrr, Dec 30, 2020.

  1. Thygrrr

    Thygrrr

    Joined:
    Sep 23, 2013
    Posts:
    705
    When I mouse over my game view (e.g. wiggling the mouse in a small circular motion), I am seeing extremely long frame times. They instantly get better again when I let go of the mouse.
    upload_2020-12-30_22-52-51.png
    These get worse over time / seemingly as DOTS physics load increases (a little).

    The kicker is, if I don't focus my right screen (which holds the game view), the frame rate stays fine. Even if I completely disable my one input that takes something from the mouse (code attached), this doesn't get better.

    Code (CSharp):
    1. using UnityEditor.PackageManager.UI;
    2. using UnityEngine;
    3. using UnityEngine.InputSystem;
    4.  
    5. public class MouseCursor : MonoBehaviour
    6. {
    7.     private RectTransform _rt;
    8.     public Texture2D cursor;
    9.  
    10.     public Camera uiCamera;
    11.  
    12.     public static Vector2 pitch;
    13.  
    14.     private void Start()
    15.     {
    16.         _rt = GetComponent<RectTransform>();
    17.         //Cursor.SetCursor(cursor, new Vector2(15,15), CursorMode.Auto);
    18.         //Cursor.visible = true;
    19.     }
    20.  
    21.     private void Update()
    22.     {
    23.         var position = Mouse.current.position.ReadValue();
    24.         _rt.position = position;
    25.  
    26.         var relative_to_center = (position - Screen.safeArea.center);
    27.         relative_to_center.x /= Screen.width;
    28.         relative_to_center.y /= Screen.height;
    29.  
    30.         relative_to_center *= 3.0f;
    31.  
    32.         if (Mathf.Abs(relative_to_center.x) > 1)
    33.             relative_to_center.x = Mathf.Sign(relative_to_center.x);
    34.  
    35.         if (Mathf.Abs(relative_to_center.y) > 1)
    36.             relative_to_center.y = Mathf.Sign(relative_to_center.y);
    37.  
    38.  
    39.         relative_to_center.x = Mathf.Pow(relative_to_center.x, 3);
    40.         relative_to_center.y = Mathf.Pow(relative_to_center.y, 3);
    41.      
    42.         pitch = relative_to_center;
    43.     }
    44. }
    45.  

    This is with Input System 1.1 on Unity 2020.1.

    Question: Does Inputsystem do anything with, or make any assumptions about DOTS, any of its system groups, or DOTS physics in particular? Going on a limb here, but that was the last thing I was working on.

    I repeat: There is no mouse input code in the game now, and it still does this.
     
    Last edited: Dec 30, 2020
  2. Thygrrr

    Thygrrr

    Joined:
    Sep 23, 2013
    Posts:
    705