OnUserInput not working on 2017.1.5f1

9_th_cu2
3d
#1

I copied the exact text for the function:

void OnUserInput(string input)
{
print("The user typed " + input);
}

Nothing is showing up on the console at all!?!

Where is OnUserInput declared anyways? I looked through all the other scripts (Terminal, Keyboard, DisplayBuffer, InputBuffer, Utility, Display) and cannot find any reference at all to this. Am I missing something after importing my package?

print works fine if I just print something in the main function.

#2

Hi,

OnUserInput is declared in your class. However, the method gets called from another instance. Look for “OnUserInput” in the Terminal class.

Did you attach your script to a game object in your Hierarchy? Did you click on the Play button? Are the messages in your console enabled?

#3

Thanks Nina, Hacker script is attached to the main object as described. When I run (press Play), everything else comes up fine on the monitor, but when I press a button, it does not display on the console. It doesn’t appear that the program picks up on the keypresses. Terminal script is attached to “Terminal”, as it was by default when dropping in the prefab at the beginning. I do see a reference to OnUserInput inside that script, under NotifyCommandHandlers.

Also, messages in console are enabled. Print works fine if I put it in the main method, just not when I put it in OnUserInput.

EDIT: OMG, I’m an idiot. It doesn’t output anything until after I press enter. I thought each keypress would trigger it, lol. Thanks!

#4

I’m glad the solution was so simple. :slight_smile:


See also: