Search code examples
unity-game-engineunity-webgl

How do I set WebGLInput.captureAllKeyboardInput to false?


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/Documentation/ScriptReference/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.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DisableKeyboardInput : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        WebGLInput.captureAllKeyboardInput = false;
    }
}

Solution

  • Fixed it by replacing WebGLInput.captureAllKeyboardInput = false; with UnityEngine.WebGLInput.captureAllKeyboardInput = false;