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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Input System with TMPro InputField gives error

Discussion in 'Input System' started by ohhboi427, Jun 30, 2020.

  1. ohhboi427

    ohhboi427

    Joined:
    Jan 31, 2020
    Posts:
    2

    I get this error every time if i click on a TMPro InputField but not with the normal InputField. I can change values with it, but it's annoying to get this error every time.
     
  2. NibblesMeKibbles

    NibblesMeKibbles

    Joined:
    May 23, 2014
    Posts:
    3
    Am receiving the same error using InputField (TMPro) with the new Input System package. Pasting error text for easier search results:

    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.
    UnityEngine.Input.GetKey (UnityEngine.KeyCode key) (at <2db13ba0d52343228aa9892c408fb49a>:0)
    TMPro.TMP_InputField.OnPointerDown (UnityEngine.EventSystems.PointerEventData eventData) (at Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Runtime/TMP_InputField.cs:1673)
     
  3. NibblesMeKibbles

    NibblesMeKibbles

    Joined:
    May 23, 2014
    Posts:
    3
    When the error pops up, select the file name in the stack-trace to jump to line #1673 of TMP_InputField.cs. Comment out the line and declare shift as false. There is no noticeable loss of functionality after trying all combinations of keys and mouse input, and the error has gone away.

    Code (CSharp):
    1. //bool shift = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
    2. bool shift = false;
     
  4. ohhboi427

    ohhboi427

    Joined:
    Jan 31, 2020
    Posts:
    2
    It works, but when I restart Unity it resets to default