GFInputDetectionResult¶
API Reference / Standard / 类索引
- 路径:
addons/gf/standard/input/rebinding/gf_input_detection_result.gd - 模块:
Standard - 继承:
RefCounted - API:
public - 类别:值对象 (
value_object) - 首次版本:
8.0.0
输入检测结束结果。 表达 GFInputDetector 一轮检测为什么结束,以及成功时捕获到的输入事件。 它不处理冲突、不修改 InputMap,也不绑定具体改键 UI 流程。
成员概览¶
| 类型 | 名称 | 签名 |
|---|---|---|
| 枚举 | FinishReason |
enum FinishReason |
| 属性 | reason |
var reason: FinishReason = FinishReason.CANCELLED |
| 属性 | input_event |
var input_event: InputEvent = null |
| 属性 | elapsed_seconds |
var elapsed_seconds: float = 0.0 |
| 属性 | value_type |
var value_type: int = -1 |
| 属性 | allowed_device_types |
var allowed_device_types: Array[int] = [] |
| 方法 | create |
static func create( finish_reason: FinishReason, detected_event: InputEvent = null, detection_elapsed_seconds: float = 0.0, detection_value_type: int = -1, detection_allowed_device_types: Array[int] = [] ) -> GFInputDetectionResult: |
| 方法 | is_success |
func is_success() -> bool: |
| 方法 | has_input_event |
func has_input_event() -> bool: |
| 方法 | to_dictionary |
func to_dictionary() -> Dictionary: |
| 方法 | reason_to_string |
static func reason_to_string(finish_reason: FinishReason) -> StringName: |
枚举¶
FinishReason¶
- API:
public - 首次版本:
8.0.0
enum FinishReason {
## 已检测到可接受输入。
SUCCESS,
## 调用方或取消输入结束了检测。
CANCELLED,
## 检测超时结束。
TIMEOUT,
## 新一轮检测替换了上一轮检测。
REPLACED,
}
检测结束原因。
属性¶
reason¶
- API:
public - 首次版本:
8.0.0
检测结束原因。
input_event¶
- API:
public - 首次版本:
8.0.0
捕获到的输入事件。只有 reason 为 SUCCESS 时应非空。
elapsed_seconds¶
- API:
public - 首次版本:
8.0.0
本轮检测经过的秒数。
value_type¶
- API:
public - 首次版本:
8.0.0
本轮检测使用的动作值类型;-1 表示未限制。
allowed_device_types¶
- API:
public - 首次版本:
8.0.0
本轮检测允许的设备类型。
结构:
allowed_device_types: Array[int],包含 GFInputDetector.DeviceType 枚举值;为空表示未限制。
方法¶
create¶
- API:
public - 首次版本:
8.0.0
static func create( finish_reason: FinishReason, detected_event: InputEvent = null, detection_elapsed_seconds: float = 0.0, detection_value_type: int = -1, detection_allowed_device_types: Array[int] = [] ) -> GFInputDetectionResult:
创建检测结束结果。
参数:
| 名称 | 说明 |
|---|---|
finish_reason |
检测结束原因。 |
detected_event |
捕获到的输入事件;非成功结果应传 null。 |
detection_elapsed_seconds |
本轮检测经过的秒数。 |
detection_value_type |
本轮检测使用的动作值类型;-1 表示未限制。 |
detection_allowed_device_types |
本轮检测允许的设备类型。 |
返回:检测结果。
结构:
detection_allowed_device_types: Array[int],包含 GFInputDetector.DeviceType 枚举值;为空表示未限制。
is_success¶
- API:
public - 首次版本:
8.0.0
检测是否成功捕获输入事件。
返回:成功捕获输入事件时返回 true。
has_input_event¶
- API:
public - 首次版本:
8.0.0
检测结果是否包含输入事件。
返回:包含输入事件时返回 true。
to_dictionary¶
- API:
public - 首次版本:
8.0.0
转换为 JSON 安全字典。
返回:检测结果字典。
结构:
return: Dictionary with reason, success, elapsed_seconds, value_type, allowed_device_types, and input_identity fields.
reason_to_string¶
- API:
public - 首次版本:
8.0.0
获取结束原因的稳定字符串。
参数:
| 名称 | 说明 |
|---|---|
finish_reason |
检测结束原因。 |
返回:结束原因字符串。