System API
System API
GetSystemInfoSync()
同步查询完整系统信息。
返回值 (SystemInfo):
| 字段 | 类型 | 说明 |
|---|---|---|
platform | string | 平台 ("ios" / "android") |
brand | string | 设备品牌 |
model | string | 设备型号 |
system | string | 操作系统及版本 |
pixelRatio | float | 像素比 |
screenWidth / screenHeight | float | 屏幕尺寸 (px) |
windowWidth / windowHeight | float | 可用区域 (px) |
safeArea | SafeArea | 安全区域信息 |
benchmarkLevel | int | 性能等级 (Android) |
SDKVersion | string | SDK 版本 |
wifiEnabled | bool | Wi-Fi 启用状态 |
environment | string | 访问环境 ("prod" / "dev") |
SystemInfo info = TudadaSDK.Instance.GetSystemInfoSync();
Debug.Log("平台: " + info.platform);
Debug.Log("屏幕: " + info.windowWidth + " x " + info.windowHeight);
Debug.Log("SafeArea: " + info.safeArea.width + " x " + info.safeArea.height);
Debug.Log("型号: " + info.model);
Debug.Log("性能等级: " + info.benchmarkLevel);
Debug.Log("Wi-Fi: " + info.wifiEnabled);
Debug.Log("环境: " + info.environment); // "prod" 或 "dev"
GetSystemInfo(onSuccess, onFail)
异步查询完整系统信息。
参数:
| 参数 | 类型 | 必须 | 说明 |
|---|---|---|---|
onSuccess | Action<SystemInfo> | - | 成功回调 |
onFail | Action<string> | - | 失败回调 |
TudadaSDK.Instance.GetSystemInfo(
onSuccess: (info) => Debug.Log("平台: " + info.platform),
onFail: (err) => Debug.LogError(err)
);
GetWindowInfo()
同步查询窗口/屏幕尺寸及 SafeArea。
返回值 (WindowInfo):
| 字段 | 类型 | 说明 |
|---|---|---|
screenWidth | float | 屏幕宽度 (px) |
screenHeight | float | 屏幕高度 (px) |
windowWidth | float | 可用区域宽度 (px) |
windowHeight | float | 可用区域高度 (px) |
safeArea | SafeArea | 安全区域信息 |
WindowInfo windowInfo = TudadaSDK.Instance.GetWindowInfo();
Debug.Log("SafeArea top: " + windowInfo.safeArea.top);
Debug.Log("屏幕尺寸: " + windowInfo.screenWidth + " x " + windowInfo.screenHeight);
GetAppBaseInfo()
同步查询应用/SDK 基本信息。
返回值 (AppBaseInfo):
| 字段 | 类型 | 说明 |
|---|---|---|
SDKVersion | string | SDK 版本 |
theme | string | 主题 |
environment | string | 访问环境 ("prod" / "dev") |
AppBaseInfo appInfo = TudadaSDK.Instance.GetAppBaseInfo();
Debug.Log("SDK版本: " + appInfo.SDKVersion);
Debug.Log("主题: " + appInfo.theme);
Debug.Log("环境: " + appInfo.environment); // "prod" 或 "dev"
GetDeviceInfo()
同步查询设备硬件信息。
返回值 (DeviceInfo):
| 字段 | 类型 | 说明 |
|---|---|---|
brand | string | 设备品牌 |
model | string | 设备型号 |
DeviceInfo deviceInfo = TudadaSDK.Instance.GetDeviceInfo();
Debug.Log("品牌: " + deviceInfo.brand);
Debug.Log("型号: " + deviceInfo.model);
GetMenuButtonBoundingClientRect()
同步查询菜单按钮位置。用于 UI 布局。
返回值 (MenuButtonRect):
| 字段 | 类型 | 说明 |
|---|---|---|
top | float | 顶部位置 |
right | float | 右侧位置 |
bottom | float | 底部位置 |
left | float | 左侧位置 |
width | float | 宽度 |
height | float | 高度 |
MenuButtonRect rect = TudadaSDK.Instance.GetMenuButtonBoundingClientRect();
Debug.Log("菜单按钮位置: top=" + rect.top + ", right=" + rect.right);