WebGL Keyboard input

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
LilGames
Posts: 29
Joined: Fri Jul 07, 2023 6:38 pm

WebGL Keyboard input

Post 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?
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: WebGL Keyboard input

Post 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().
LilGames
Posts: 29
Joined: Fri Jul 07, 2023 6:38 pm

Re: WebGL Keyboard input

Post by LilGames »

Excellent suggestion!
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: WebGL Keyboard input

Post by Tony Li »

Glad to help!
Post Reply