Forum rules - please read before posting.

Input System throws continuous error

edited August 3 in Technical Q&A

Hey Chris,

after switching to the "new" input system, I get caught in an endless error loop after hitting play in the editor. It piles up the following message:

NullReferenceException: Object reference not set to an instance of an object
AC.Templates.InputSystemIntegration.ControlsReader.Custom_GetMouseButtonDown (System.Int32 button) (at Assets/AdventureCreator/Scripts/Templates/InputSystem/Scripts/ControlsReader.cs:216)
AC.PlayerInput.InputGetMouseButtonDown (System.Int32 button) (at Assets/AdventureCreator/Scripts/Controls/PlayerInput.cs:1878)
AC.PlayerInput.UpdateInput () (at Assets/AdventureCreator/Scripts/Controls/PlayerInput.cs:323)
AC.StateHandler.Update () (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:188)

The game is set up for touch input and has movement set to "none".

I am on Unity 6.3 on a Mac and AC 1.86.4

Two things that might or might not be related but that I can't make sense of:

1.
The "Input Debugger" that can be opened via the Player Input Script on the "EventSystem_ InputSystem" prefab created by the AC NewGame Wizard (of which I have used the "modify" option to switch the Input System on) shows by default:

Devices (0) -> Unsupported (3) -> Keyboard (OSX) • Mouse (OSX) • Pen (OSX).

If I now activate "Add devices Not Listed in 'Supported Devices'" from the Options Dropdown, the window changes to

Devices (3) -> Keyboard • Mouse • Pen

and the error goes away and the UI becomes responsive.

But what should be the takeaway for me from this? What would I have to do in order to get rid of the error altogether?

2.
In "Controls (Input Actions Editor"), under "UI" I am seeing an entry very different from the others:

Point -> Position [Mouse] • Position [Pen] • touch*/position [Touchscreen]

As the option Position [Touchscreen] would available as well, I wonder what that is about?

Thanks in advance!

Best, Jens

Comments

  • And maybe I should add that the game also uses AR input … but not in the the scene that produces the error above.

  • The error itself seems to be indicating that your mouse isn't available for input-reading in your project. I'm not sure why that would be, but when testing Touch Screen in the Editor, AC will fallback to mouse input.

    You can uncheck Mouse clicks have default functionality? in the Settings Manager to prevent AC from reading mouse clicks, but it sounds like your tinkering of supported devices in the Input Debugger is the true fix, as it's then allowing the mouse to be read.

  • edited August 4

    By deleting everything related to the input system and reinstalling it, I got rid of the error … but only in the editor.

    When running the game build in Xcode (iOS), AC still does produce messages en masse (and in loop, obviously on update):

    NullReferenceException: Object reference not set to an instance of an object.
    at AC.Templates.InputSystemIntegration.ControlsReader.Custom_MousePosition (System.Boolean cursorIsLocked) [0x00000] in <00000000000000000000000000000000>:0
    at AC.PlayerInput.InputMousePosition (System.Boolean _cursorIsLocked) [0x00000] in <00000000000000000000000000000000>:0
    at AC.PlayerInput.UpdateInput () [0x00000] in <00000000000000000000000000000000>:0
    at AC.StateHandler.Update () [0x00000] in <00000000000000000000000000000000>:0

    I have been tinkering with setting combos in AC that could be "cursorIsLocked"-related all day, but I cannot get rid of this. Is there any manual or tutorial related to AC's integration with the input system that I could study?

    For clarity: For my tests, I have stripped down the game build to its opening scene only for testing purposes, and this scene consists of nothing but a canvas with menu buttons and an AC menu. As soon as the scene is loaded, the error loop starts … I can click the buttons, though, and they do respond, too.

  • Do these errors occur when running a native build on iOS?

    The Update loop only invokes InputMousePosition if:

    • Input method is set to Mouse And Keyboard, or
    • Input method is set to Touch Screen, and you're testing in the Editor

    I wouldn't expect running in Xcode to treat the game as though you're in the Editor, but you can have AC skip the second case above by opening its PlayerInput script and replacing the code block from line 263:

    #if UNITY_EDITOR
        if (KickStarter.settingsManager.inputMethod == InputMethod.MouseAndKeyboard || KickStarter.settingsManager.inputMethod == InputMethod.TouchScreen)
    #else
        if (KickStarter.settingsManager.inputMethod == InputMethod.MouseAndKeyboard)
    #endif
    

    with:

    if (KickStarter.settingsManager.inputMethod == InputMethod.MouseAndKeyboard)
    

    Does that suppress the errors in Xcode?

  • These errors occur after exporting the iOS build from Unity, opening it in Xcode 26.5 (and either removing MacOS and visionOS from the "supported destinations" or not – makes no difference), so yes: it is a native build.

    But there is another thing I just witnessed:

    as I already mentioned, …

    • right now the start scene is just a canvas with buttons that take me to other scenes when clicked / tapped on.
    • movement method is set to "None" in AC settings manager, input method to "Touchscreen".

    Now, as soon as I enter Play Mode the editor and tap / click on any of those buttons on the canvas, the input method of the AC settings manager gets changed from "Touchscreen" to "Mouse and Keyboard".
    I understand that this is intended behavior, as you mentioned above

    Input method is set to Touch Screen, and you're testing in the Editor

    But after I exit Play Mode, the setting remains at "Mouse and Keyboard"; it is not switching back to "Touchscreen". So obviously entering Play Mode has some sort of permanent effect on AC's settings manager which I guess is not intended behavior.

    Could that be a clue on what is going on?

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.