Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug New input system, Move:2D Vector null in build (unity 2019.4.15f1 LTS and 2019.4.17f1 LTS)

Discussion in 'Input System' started by Erenquin, Jan 3, 2021.

  1. Erenquin

    Erenquin

    Joined:
    Apr 9, 2018
    Posts:
    164
    Hello,
    pretty much as the title says.

    Inputs work perfectly in editor, not at all in the build.

    I'm using 2019.4.15f1 LTS and checked with 2019.4.17f1 LTS as well.
    I upgraded the package to the latest version (1.0.1)

    I have already checked different things I found on Google like:
    Player is set to Input System Package (new)
    I build in Mono / .Net standard 2.0
    I build for Windows in x86_64 architecture.

    I'm using a similar system than the one used in the Open project.

    Yet in player log I have this message:
    New input system (experimental) initialized
    <RI> Initialized touch support.

    NullReferenceException while resolving binding 'Move:2DVector' in action map 'PlayerActions (UnityEngine.InputSystem.InputActionAsset):Movement'
    (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)

    It is actually at the ".enable" call:
    I tried both:
    Code (CSharp):
    1.  
    2.     private void OnEnable()
    3.     {
    4.         if (actions == null)
    5.         {
    6.             actions = new PlayerActions();
    7.             actions.Movement.SetCallbacks(this);
    8.             actions.Look.SetCallbacks(this);
    9.             actions.Fire.SetCallbacks(this);
    10.         }
    11.         actions.Enable();
    12.     }
    13.  
    and:
    Code (CSharp):
    1.    private void OnEnable()
    2.     {
    3.         if (actions == null)
    4.         {
    5.             actions = new PlayerActions();
    6.             actions.Movement.SetCallbacks(this);
    7.             actions.Look.SetCallbacks(this);
    8.             actions.Fire.SetCallbacks(this);
    9.         }
    10.         actions.Movement.Enable();
    11.         actions.Look.Enable();
    12.         actions.Fire.Enable();
    13.     }
    I tried by renaming the "actions" variable, just in case it would collide with a reserved word (aka "event Action", ...). Did not help.

    If I remove the call "playerActions.Enable();", then I do not get this error.
    So the issue is clearly there.
    I also tried:
    Code (CSharp):
    1.         if (playerActions == null)
    2.         {
    3.             playerActions = new PlayerActions();
    4.             /*
    5.             playerActions.Movement.SetCallbacks(this);
    6.             playerActions.Look.SetCallbacks(this);
    7.             playerActions.Fire.SetCallbacks(this);
    8.             */
    9.             playerActions.Enable();
    10.         }
    But why ?
    Why is it null right after the call to new ?
    Why isn't it null when running in the editor ?

    I'm short of ideas to solve this problem.

    PS: here is the complete log:
    Code (CSharp):
    1.  
    2. NullReferenceException while resolving binding 'Move:2DVector' in action map 'PlayerActions (UnityEngine.InputSystem.InputActionAsset):Movement'
    3. (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)
    4.  
    5. NullReferenceException: Object reference not set to an instance of an object
    6.   at UnityEngine.InputSystem.Utilities.TypeTable.LookupTypeRegistration (System.String name) [0x00020] in <28730f2cc83a467c9f1b8d3ae95b5406>:0
    7.   at UnityEngine.InputSystem.InputBindingResolver.InstantiateBindingComposite (System.String nameAndParameters) [0x00013] in <28730f2cc83a467c9f1b8d3ae95b5406>:0
    8.   at UnityEngine.InputSystem.InputBindingResolver.AddActionMap (UnityEngine.InputSystem.InputActionMap map) [0x00336] in <28730f2cc83a467c9f1b8d3ae95b5406>:0
    9. UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
    10. UnityEngine.DebugLogHandler:LogException(Exception, Object)
    11. UnityEngine.Logger:LogException(Exception, Object)
    12. UnityEngine.Debug:LogException(Exception)
    13. UnityEngine.InputSystem.InputBindingResolver:AddActionMap(InputActionMap)
    14. UnityEngine.InputSystem.InputActionMap:ResolveBindings()
    15. UnityEngine.InputSystem.InputActionMap:ResolveBindingsIfNecessary()
    16. UnityEngine.InputSystem.InputActionMap:Enable()
    17. UnityEngine.InputSystem.InputActionAsset:Enable()
    18. PlayerActions:Enable()
    19. PlayerInputReader:OnEnable()
    20.  
     
    Last edited: Jan 3, 2021
  2. Erenquin

    Erenquin

    Joined:
    Apr 9, 2018
    Posts:
    164
    If I remove the "Move" Actions, then what remains (mouse look and fire) work perfectly in the build.
    I have checked the setup is exactly as in the "Open Project":
    upload_2021-1-4_17-36-35.png

    And the "2D Vector" bindings:
    upload_2021-1-4_17-39-4.png

    As a side note, the Open Project does not build (tried Main and Master branches) so I can't test if the key binding work for it (in build).
     
  3. Erenquin

    Erenquin

    Joined:
    Apr 9, 2018
    Posts:
    164
    If I change to 1D Axis binding I get the same issue (works perfectly in editor, null in build):
    upload_2021-1-4_17-56-5.png

    NullReferenceException while resolving binding 'Move:1DAxis' in action map 'PlayerActions (UnityEngine.InputSystem.InputActionAsset):Movement'
    (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)
     
  4. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
    Question: why are you not using .NET 4.x? It's required by the InputSystem.
     
  5. Erenquin

    Erenquin

    Joined:
    Apr 9, 2018
    Posts:
    164
    Thanks for the check,
    I think at the time I tried .NET 4.x, but, to be sure I tried it right now and I got the same issue.
    I also tried to build in IL2CPP / .NET 4.x, same issue, but clearer log, in the sense that the parameters are clearly NULL:


    NullReferenceException while resolving binding 'Move:2DVector' in action map 'PlayerActions (UnityEngine.InputSystem.InputActionAsset):Movement'
    UnityEngine.Logger:Log(LogType, Object)
    UnityEngine.Debug:LogError(Object)
    UnityEngine.InputSystem.InputBindingComposite:GetValueType(String)
    UnityEngine.InputSystem.InputActionMap:ResolveBindings()
    UnityEngine.InputSystem.InputActionAsset:Enable()
    (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)

    NullReferenceException: Object reference not set to an instance of an object.
    at UnityEngine.InputSystem.Utilities.TypeHelpers.IsInt (System.TypeCode type) [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.InputSystem.InputBindingResolver.InstantiateBindingComposite (System.String nameAndParameters) [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.InputSystem.InputBindingComposite.GetValueType (System.String composite) [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.InputSystem.InputActionMap.ResolveBindings () [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.InputSystem.InputActionAsset.Enable () [0x00000] in <00000000000000000000000000000000>:0
    UnityEngine.Logger:LogException(Exception, Object)
    UnityEngine.Debug:LogException(Exception)
    UnityEngine.InputSystem.InputBindingComposite:GetValueType(String)
    UnityEngine.InputSystem.InputActionMap:ResolveBindings()
    UnityEngine.InputSystem.InputActionAsset:Enable()
     
  6. Erenquin

    Erenquin

    Joined:
    Apr 9, 2018
    Posts:
    164
    Further trials:
    as I could build the Open Project and it runs perfectly, I spent time again comparing the input implementations and I do not see the difference.
    I renamed the "2D Vector" action to "Keyboard WASD" upload_2021-1-7_18-25-15.png

    Now when I search the Visual studio project, the only occurence of "2DVector" in my project is in the generated Json asset:
    Code (JavaScript):
    1.             ""bindings"": [
    2.                 {
    3.                     ""name"": ""KeyboardWASD"",
    4.                     ""id"": ""c332d6b3-f832-4245-98dc-88c8e1891664"",
    5.                     ""path"": ""2DVector"",
    6.                     ""interactions"": """",
    7.                     ""processors"": """",
    8.                     ""groups"": """",
    9.                     ""action"": ""Move"",
    10.                     ""isComposite"": true,
    11.                     ""isPartOfComposite"": false
    12.                 },
    And this is the one in Open Project:
    Code (JavaScript):
    1.               {
    2.                     ""name"": ""Keyboard WASD"",
    3.                     ""id"": ""f8b893c4-85c2-492d-89ab-41f8d1520def"",
    4.                     ""path"": ""2DVector"",
    5.                     ""interactions"": """",
    6.                     ""processors"": ""ScaleVector2(x=0.6,y=0.6)"",
    7.                     ""groups"": """",
    8.                     ""action"": ""Move"",
    9.                     ""isComposite"": true,
    10.                     ""isPartOfComposite"": false
    11.                 },
    I also "downgraded" my project to 2019.4.14f1 (the same version as Open Project) and ensured I have the same version of the Input system (1.0.0).

    I still get the NULL error (now building in IL2CPP / .NET 4x, to also be consistent with Open Project):
    NullReferenceException while resolving binding 'Move:2DVector' in action map 'PlayerActions (UnityEngine.InputSystem.InputActionAsset):Movement'
     
  7. Erenquin

    Erenquin

    Joined:
    Apr 9, 2018
    Posts:
    164
    In "InputBindingResolver.cs", I added a debug log in AddActionMap:
    Code (CSharp):
    1.                 for (var n = 0; n < bindingCountInThisMap; ++n)
    2.                 {
    3.                     var bindingStatesPtr = newMemory.bindingStates;
    4.                     ref var unresolvedBinding = ref bindingsInThisMap[n];
    5.                     var bindingIndex = bindingStartIndex + n;
    6.                     var isComposite = unresolvedBinding.isComposite;
    7.                     var isPartOfComposite = !isComposite && unresolvedBinding.isPartOfComposite;
    8.                     var bindingState = &bindingStatesPtr[bindingIndex];
    9.                     //TOREMOVE
    10.                     Debug.LogError(unresolvedBinding);
    And the build executions outputs:
    Code (CSharp):
    1. Move:2DVector
    2. (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)
    3.  
    4. Move:<Keyboard>/w
    5. (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)
    6.  
    7. Move:<Keyboard>/s
    8. (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)
    9.  
    10. Move:<Keyboard>/a
    11. (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)
    12.  
    13. Move:<Keyboard>/d
    14. (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)
    This shows that Move:2DVector exists somewhere.
     
  8. unity_Aethm04I9Lib4w

    unity_Aethm04I9Lib4w

    Joined:
    Aug 19, 2020
    Posts:
    1
    Having the same issue on Unity 2020.1.2f1. Don't know how to fix it.
    Tried to regenerate ActionCollection class, but have no success.

    NullReferenceException while resolving binding 'Move:2DVector' in action map 'PlayerControls (UnityEngine.InputSystem.InputActionAsset):CrewmateControls'
    (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)
     
  9. emrodk

    emrodk

    Joined:
    Feb 12, 2021
    Posts:
    4
    I had this same problem creating the action asset, my solution was to stick with Unity 2020.1.14f1 until yesterday. After Unity 2020.1.14f1, something changed in how the asset should be enabled.
    If you are using a MonoBehaviour then follow these steps:
    1. Create the action asset in Awake ()
    2. Subscribe to any event you need
    3. Enable the asset in the OnEnable () method (to disable use OnDisable)
    4. Add InputSystem.Update () in the Update () method
    If you are using a SystemBase (DOTS):
    1. Create the action asset in OnCreate ()
    2. Subscribe to any event you need
    3. Enable the asset in the OnStartRunning () method (to disable use OnStopRunning)
    4. Add InputSystem.Update () in the OnUpdate () method
     
    DrBoum and PhilSA like this.
  10. cuikeqiang

    cuikeqiang

    Joined:
    Nov 16, 2019
    Posts:
    5
    I set callbacks in ScriptableObject (like unity open project's InputReader: https://github.com/UnityTechnologie...1_Project/Assets/Scripts/Input/InputReader.cs), I have the same binding 'Move:2DVector' problem, what should I do?
     
  11. wechat_os_Qy07oG6LBuLwxrt0ao4ZkEwPc

    wechat_os_Qy07oG6LBuLwxrt0ao4ZkEwPc

    Joined:
    Jun 28, 2021
    Posts:
    17
    Having the same issue on Unity 2020.3.7f1. Don't know how to fix it.
    the version Verify is a joker.

    Logger putout :
    NullReferenceException while resolving binding 'Move:Dpad' in action map 'InputActions (UnityEngine.InputSystem.InputActionAsset):CharacterController'

    (now building in Mono / .NET 4x, to also be consistent with Open Project):
     
  12. cuikeqiang

    cuikeqiang

    Joined:
    Nov 16, 2019
    Posts:
    5
    How to 'Create the action asset ' in Awake()?? what does the code look like?
     
  13. crazyjackel

    crazyjackel

    Joined:
    Oct 10, 2018
    Posts:
    18
    Experiencing the Same Exact Error in my built version. I am using version 1.0.2 of the Input System. It seems to be some sort of error with the composite system.

    My error is in the TypeTable here where I am getting a null reference exception. I am assuming that the table variable might be null and not initialized.

    NullReferenceException: Object reference not set to an instance of an object
    at UnityEngine.InputSystem.Utilities.TypeTable.LookupTypeRegistration (System.String name) [0x00020] in <16a80d22088b46bc8b88d3d4a80f8054>:0
    at UnityEngine.InputSystem.InputBindingResolver.InstantiateBindingComposite (System.String nameAndParameters) [0x00013] in <16a80d22088b46bc8b88d3d4a80f8054>:0
    at UnityEngine.InputSystem.InputBindingResolver.AddActionMap (UnityEngine.InputSystem.InputActionMap map) [0x00336] in <16a80d22088b46bc8b88d3d4a80f8054>:0



    Code (CSharp):
    1.  public Type LookupTypeRegistration(string name)
    2.         {
    3.             if (string.IsNullOrEmpty(name))
    4.                 throw new ArgumentException("Name cannot be null or empty", nameof(name));
    5.  
    6.             var internedName = new InternedString(name);
    7.             if (table.TryGetValue(internedName, out var type))
    8.                 return type;
    9.             return null;
    10.         }
     
  14. dmytro_at_unity

    dmytro_at_unity

    Unity Technologies

    Joined:
    Feb 12, 2021
    Posts:
    212
    By any chance, are you trying to enable actions from some place very early in the initialization process?

    We rely on
    InputSystem.InputSystem()
    static constructor in our assembly to bootstrap ourselves, and trying to use the system before that might yield similar errors.

    To check that put a breakpoint in your code right before call to actionmap.Enable and in input system code inside
    InputSystem.InputSystem()
    static constructor and see which is called first
     
  15. crazyjackel

    crazyjackel

    Joined:
    Oct 10, 2018
    Posts:
    18

    Static Constructor is called first when testing in editor. I am using onEnable() for the InputReader. My code works in the editor, but in the build there is some trouble.
     
  16. crazyjackel

    crazyjackel

    Joined:
    Oct 10, 2018
    Posts:
    18
    I deferred from OnEnable to Start in another script for Enabling the Movement and that seems to prevent the error in the build.
     
  17. dmytro_at_unity

    dmytro_at_unity

    Unity Technologies

    Joined:
    Feb 12, 2021
    Posts:
    212
    Ok I think I know what is going on,
    RuntimeInitializeLoadType.BeforeSceneLoad
    might be called after
    Awake
    and
    OnEnable

    Would you mind to create a bug report for this one please?
     
  18. Erenquin

    Erenquin

    Joined:
    Apr 9, 2018
    Posts:
    164
    Nice to see this being addressed :)
     
  19. ahstein

    ahstein

    Joined:
    Jan 9, 2018
    Posts:
    2
    For posterity:

    I experienced a bug that looks essentially identical to these issues. I fixed it by deleting the 2D composite action and remaking it. I noticed that the 2D composite binding option is now something like "Up/Down/Left/Right composite" while it used to be something like "digital 2D composite." I believe that I made the asset originally using an older version of the input system and the way 2D composite actions/bindings are handled change in a way that makes the old asset incompatible (but only in builds).
     
  20. dmytro_at_unity

    dmytro_at_unity

    Unity Technologies

    Joined:
    Feb 12, 2021
    Posts:
    212
    @ahstein I've double checked, nothing really changed in vector2 composite lately, do you have any ability to repro the case maybe? copy of an old asset maybe?
     
  21. ahstein

    ahstein

    Joined:
    Jan 9, 2018
    Posts:
    2
    Yep, I submitted a bug report with a stripped down project that repros the issue for me.
    https://fogbugz.unity3d.com/default.asp?1378614_4lr2jfl4p8v2r0ua
    case#: 1378614

    Everything I tested was on Unity version 2020.3.18f1, the problem occurred in both the 1.0.2 and 1.2.0 versions of the Input System package, and it occurred in builds for all platforms I tried (Windows x64 dev and WebGL dev).

    I believe I created this asset using a 2019 version of the Input System package and copy/pasted it from an older project.

    If you have additional questions, emailing me at the address provided with the bug report is a more reliable way for me to see them than responding here.
     
  22. Harsh-NJ

    Harsh-NJ

    Joined:
    May 1, 2020
    Posts:
    315
    Hey @Erenquin , has this been fixed for you??
    If not, then I was having the same issue, (but with Move:1DAxis), and what I did is removed and remade that binding after updating InputSystem to 1.2.0, and inputs are now working perfectly in build. All initializing was done in OnEnable method and used no Awake method.
    Hope this fixes.
    Thanks.
     
  23. Erenquin

    Erenquin

    Joined:
    Apr 9, 2018
    Posts:
    164
    Hello,
    no, my OP was in january :), so in, the meantime I implemented the input system differently for it to work.
    I did not try the original variant of the implementation with the new version of the package.
    I spent so much time already on that that now I stick with my working implementation.
     
  24. Andruxin52rus

    Andruxin52rus

    Joined:
    Jul 5, 2020
    Posts:
    3
    Also had this issue with Unity 2020.3.22. What finally helped me was mimicking one of new Input System samples called "Simple Demo", which goes with the package (1.0.2 version in my case).
    My scenario was close to SimpleController_UsingActionAsset out of this sample. It's useful to take a look at samples sometimes, because it's so easy to misuse some features or stumble across weird bugs
     
  25. dmytro_at_unity

    dmytro_at_unity

    Unity Technologies

    Joined:
    Feb 12, 2021
    Posts:
    212
  26. Sayama

    Sayama

    Joined:
    Feb 9, 2019
    Posts:
    1
    Hi, I'm using Unity 2020.3.32f1 (and the Input System 1.3.0) but I still got the problem. I suppose it's because it's fix in the 1.4.0 but as I can't (or don't know how to) use it, I still got the problem.

    I'm Building for Windows Standalone (x86_64)
     
  27. SMT5015

    SMT5015

    Joined:
    Apr 5, 2021
    Posts:
    53
    I do. (And, believe it or not, my problematic action is also a 2D vector called "Move") Though I'm not sure if I'm using right version. Can't find any hints in the fix report.
     
  28. wihu

    wihu

    Joined:
    Nov 22, 2012
    Posts:
    25
    Just adding more info, I had similar issue, 2d vector/composite bindings not working on WebGL build, upgrading input system package to 1.5.1 fixed it for me.