Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question How do I set WebGLInput.captureAllKeyboardInput to false?

Discussion in 'Input System' started by RobertBlaauw, Sep 12, 2020.

  1. RobertBlaauw

    RobertBlaauw

    Joined:
    Jan 5, 2020
    Posts:
    3
    I'm building my Unity project to WebGL and on the same page where the Unity container is loaded I have some HTML input fields. But because Unity is using all of the keyboard input I am not able to type in those fields. According to this: https://docs.unity3d.com/2020.1/Doc...rence/WebGLInput-captureAllKeyboardInput.html there is an option to set captureAllKeyboardInput to false. But how do I use this. If I create an empty game object with the following script is does not work.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class DisableKeyboardInput : MonoBehaviour
    6. {
    7.     // Start is called before the first frame update
    8.     void Start()
    9.     {
    10.         WebGLInput.captureAllKeyboardInput = false;
    11.     }
    12. }
     
  2. RobertBlaauw

    RobertBlaauw

    Joined:
    Jan 5, 2020
    Posts:
    3
    I am now getting the follow error in my console:

    MissingMethodException: Attempted to access a missing method.
    DisableKeyboardInput.Start () (at Assets/Scripts/DisableKeyboardInput.cs:10)
     
  3. RobertBlaauw

    RobertBlaauw

    Joined:
    Jan 5, 2020
    Posts:
    3
    Fixed it by replacing
    WebGLInput.captureAllKeyboardInput = false;
    with
    UnityEngine.WebGLInput.captureAllKeyboardInput = false;