Page 1 of 1

WebGL Keyboard input

Posted: Wed Sep 20, 2023 7:56 pm
by LilGames
Hi. I've now been testing a project using Dialogue System, deployed as WebGL. I have a dialogue with a request for the player name, but we can't type in anything. In other parts of our game we solve this by doing this before needing input:

Code: Select all

#if UNITY_WEBGL
        UnityEngine.WebGLInput.captureAllKeyboardInput = true;
#endif
.. and then this after input is done and received, so that key capture is returned to the web browser:

Code: Select all

#if UNITY_WEBGL
        UnityEngine.WebGLInput.captureAllKeyboardInput = false;
#endif
Before I hack similar code into DS, do you already have inspector settings for this somewhere?

Re: WebGL Keyboard input

Posted: Wed Sep 20, 2023 9:04 pm
by Tony Li
Hi,

Is that necessary in WebGL? The Dialogue System's web demo uses the TextInput() sequencer command, and it doesn't have any problems that I'm aware of. (Interact with the computer terminal in the center of the room to test text input.)

If this is an issue in your setup, you could set UnityEngine.WebGLInput.captureAllKeyboardInput true in an OnConversationStart method and set it false in an OnConversationEnd method. (See Script Methods.) If you need to tighten it up so it only happens during text input, you could add a script to the Text Field UI's input field child GameObject that sets it true in OnEnable() and false in OnDisable().

Re: WebGL Keyboard input

Posted: Thu Sep 21, 2023 1:15 pm
by LilGames
Excellent suggestion!

Re: WebGL Keyboard input

Posted: Thu Sep 21, 2023 3:32 pm
by Tony Li
Glad to help!