Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved (case 1341690) 2021.2.0a19 and new Imput System, weird message in console on entering play mode

Discussion in '2021.2 Beta' started by APSchmidt, Jun 7, 2021.

  1. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    4,383
    I'm learning the new input system with 2021.2; I'm pretty sure the project is set accordingly:
    • package installed,
    • .net 4.x enabled in the project settings,
    • new input system enabled in the project settings,
    • old input system disabled in the project settings,
    • player actions created and added to the Player Input component,
    • only one script added to the player containing basic movement,
    and as soon as I enter play mode, I get the following two messages in the console. These messages do not prevent entering play mode and I have no idea if they are related to something wrong in 0a19 or in the new Input System.

    Messages:
    Code (CSharp):
    1. InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings.
    2. UnityEngine.Input.get_mousePosition () (at <49f23eeeae774cc9bbc0d95529715ec2>:0)
    3. UnityEngine.UI.MultipleDisplayUtilities.GetMousePositionRelativeToMainDisplayResolution () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/MultipleDisplayUtilities.cs:40)
    4. UnityEngine.EventSystems.BaseInput.get_mousePosition () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/BaseInput.cs:75)
    5. UnityEngine.EventSystems.StandaloneInputModule.UpdateModule () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:178)
    6. UnityEngine.EventSystems.EventSystem.TickModules () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:452)
    7. UnityEngine.EventSystems.EventSystem.Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:467)
    Code (CSharp):
    1. InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings.
    2. UnityEngine.EventSystems.BaseInput.GetButtonDown (System.String buttonName) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/BaseInput.cs:126)
    3. UnityEngine.EventSystems.StandaloneInputModule.ShouldActivateModule () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:227)
    4. UnityEngine.EventSystems.EventSystem.Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:474)
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.InputSystem;
    3.  
    4. public class PlayerController : MonoBehaviour
    5. {
    6.     [SerializeField]
    7.     private float speed = 10f;
    8.     private Rigidbody rigidBody;
    9.     private float movementX;
    10.     private float movementY;
    11.  
    12.  
    13.     // Start is called before the first frame update
    14.     private void Start()
    15.     {
    16.         rigidBody = GetComponent<Rigidbody>();
    17.     }
    18.  
    19.     private void OnMove(InputValue movementValue)
    20.     {
    21.         Vector2 movementVector = movementValue.Get<Vector2>();
    22.         movementX = movementVector.x;
    23.         movementY = movementVector.y;
    24.     }
    25.  
    26.     private void FixedUpdate()
    27.     {
    28.         Vector3 movement = new Vector3(movementX, 0.0f, movementY);
    29.         rigidBody.AddForce(movement * speed);
    30.     }
    31. }
     
  2. mahdi_jeddi

    mahdi_jeddi

    Joined:
    Jul 18, 2016
    Posts:
    236
    Did you restart the Editor after changing the Input system? It offers you to do it, and without it Input System won't work properly.
     
  3. print_helloworld

    print_helloworld

    Joined:
    Nov 14, 2016
    Posts:
    231
    This isnt related to your code or setup. Your event system object is not using the input module that is provided by the input system, you need swap it out.
     
  4. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    4,383
    Thanks for the input... :D

    So, it's a problem with the editor; it doesn't switch completely out of the old input system. In the project settings, I changed the "Active Input handling" property to "Both" and the messages have disappeared. I'll try later to go back to using only the new system and see what happens.
     
  5. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    4,383
    Okay, I switched back and forth between the old and new systems and still got the messages. In the end I got a [Debug Updater] that offered to replace the input module, which I did but it didn't change anything, I'm still getting the error messages, and the same debug updater.

    Switching back to using both seems to be the only available fix for now.
     
    Last edited: Jun 7, 2021
  6. print_helloworld

    print_helloworld

    Joined:
    Nov 14, 2016
    Posts:
    231
    Again its because of the event system relying on the old input approach
     
  7. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    4,383
    Case # 1341690.
     
    LeonhardP likes this.
  8. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    4,383
    Just got the same problem in a brand new 2D project. Clicking on "Replace with InputSystemUIInputModule" does nothing, apparently.

    Capture d’écran_2021-06-08_18-38-07.jpg

     
  9. sk0g

    sk0g

    Joined:
    Mar 5, 2021
    Posts:
    33
    I've got the same thing with a19, HDRP template. The old input system isn't in use anywhere, and it's being thrown by the editor anyway I think. Don't have any interactions relating to the mouse, so it's not coming from my input actions.
     
  10. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,758
    What happens if you replace it manually?
     
  11. sk0g

    sk0g

    Joined:
    Mar 5, 2021
    Posts:
    33
    That seems to work for me. Added a Input System UI Input module to the player object, then dropped a reference to it into the Player Input. First play afterwards took ages, but been fine since then.
     
  12. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    4,383
    Wait, wait, wait, it's mentioned nowhere that we must add this component to the player in the tutorials I've followed, not even in the quick start doc! And I don't have, in any of the two projects, a "standalone input module" installed on any of the game objects present on my scene or anywhere else for that matter (especially the brand new project in which there is absolutely nothing in the project view except for the usual empty scene). So why must I replace a component that is non existing?

    I'll try that anyway but there is something that doesn't seem to be working right there.
     
  13. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,758
    https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/UISupport.html
     
  14. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    4,383
  15. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,758
    You probably have some errors which prevents the editor to compile properly so the button doesn't work. In normal circumstances you don't have to replace it manually, you just need to hit the button.

    Although IDK the workflows on linux, so I'm guessing based on the windows workflow.
     
  16. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    4,383
    No, no errors nowhere, but I think I've found something: in both projects Universal RP is installed, URP uses Unity UI which apparently is not supported by the current New Input System.

    I'm going to create a project without URP and see what happens with the Input package. :)

    Capture d’écran_2021-06-10_17-33-33.jpg
     
  17. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,758
    It is supported. Replacing this component we talked about doing that support. If you are familiar with the link I sent to you, that page is talking about Unity UGUI support.
     
  18. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    4,383
    It's a patch so that people can live with that.
     
  19. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    4,383
    So I did, and no error popped up in the console when I entered play mode. This situation is definitely linked to URP.

    I'd rather keep "Active Input handling" property to "Both", I don't feel comfortable adding the module manually. ;)
     
  20. sk0g

    sk0g

    Joined:
    Mar 5, 2021
    Posts:
    33
    I had the same error using the HDRP template, so likely just a regression introduced in a17 or a19. The two fixes that worked were adding the module manually, and changing active input handling to both. The former is a cleaner solution IMO.
     
  21. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    4,383
    Yeah, package conflicts, we didn't need this. :)
     
  22. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    4,383