Device API
Device API
振动
VibrateShort(type, onSuccess, onFail)
执行短振动(15ms)。
参数:
| 参数 | 类型 | 必须 | 说明 |
|---|---|---|---|
type | VibrateType | - | 振动强度 (heavy, medium, light) |
onSuccess | Action<VibrateShortResult> | - | 成功回调 |
onFail | Action<string> | - | 失败回调 |
TudadaSDK.Instance.VibrateShort(
type: VibrateType.medium, // heavy, medium, light
onSuccess: (result) => Debug.Log("振动执行")
);
VibrateLong(onSuccess, onFail)
执行长振动(400ms)。
参数:
| 参数 | 类型 | 必须 | 说明 |
|---|---|---|---|
onSuccess | Action<VibrateLongResult> | - | 成功回调 |
onFail | Action<string> | - | 失败回调 |
TudadaSDK.Instance.VibrateLong(
onSuccess: (result) => Debug.Log("长振动执行")
);
键盘
ShowKeyboard(defaultValue, maxLength, multiple, confirmHold, confirmType, onSuccess, onFail)
显示软键盘。
参数:
| 参数 | 类型 | 必须 | 说明 |
|---|---|---|---|
defaultValue | string | - | 默认输入值 |
maxLength | int | - | 最大输入长度 |
multiple | bool | - | 是否允许多行输入 |
confirmHold | bool | - | 确认后是否保持键盘 |
confirmType | KeyboardConfirmType | - | 确认按钮类型 |
onSuccess | Action<ShowKeyboardResult> | - | 成功回调 |
onFail | Action<string> | - | 失败回调 |
KeyboardConfirmType 选项:
| 值 | 说明 |
|---|---|
done | 完成 |
next | 下一步 |
search | 搜索 |
go | 前往 |
send | 发送 |
TudadaSDK.Instance.ShowKeyboard(
defaultValue: "",
maxLength: 100,
multiple: false,
confirmHold: false,
confirmType: KeyboardConfirmType.done,
onSuccess: (result) => Debug.Log("键盘已显示")
);
HideKeyboard()
隐藏软键盘。
TudadaSDK.Instance.HideKeyboard();
OnKeyboardInput(事件)
键盘输入变化时触发的事件。
回调参数 (KeyboardInputResult):
| 字段 | 类型 | 说明 |
|---|---|---|
value | string | 当前输入值 |
TudadaSDK.OnKeyboardInput += (result) => {
Debug.Log("输入: " + result.value);
};
OnKeyboardConfirm(事件)
点击键盘确认按钮时触发的事件。
回调参数 (KeyboardConfirmResult):
| 字段 | 类型 | 说明 |
|---|---|---|
value | string | 确认的输入值 |
TudadaSDK.OnKeyboardConfirm += (result) => {
Debug.Log("确认: " + result.value);
};
OnKeyboardComplete(事件)
键盘输入完成时触发的事件。
回调参数 (KeyboardCompleteResult):
| 字段 | 类型 | 说明 |
|---|---|---|
value | string | 最终输入值 |
TudadaSDK.OnKeyboardComplete += (result) => {
Debug.Log("完成: " + result.value);
};