Version: 2022.3

WebGLInput.captureAllKeyboardInput

切换到手册
public static bool captureAllKeyboardInput ;

描述

捕捉所有键盘输入。

此属性确定 WebGL 是否捕捉键盘输入。如果启用此属性(默认设置),无论焦点在哪里,WebGL 画布都将接收所有输入,网页中的其他元素将不会接收键盘输入。如果需要由其他 html 输入元素接收输入,则需要禁用此属性。

using UnityEngine;

public class Example : MonoBehaviour { void Start() { #if !UNITY_EDITOR && UNITY_WEBGL // disable WebGLInput.captureAllKeyboardInput so elements in web page can handle keyboard inputs WebGLInput.captureAllKeyboardInput = false; #endif } }