跳到主要内容

System API

System API

GetSystemInfoSync()

同步查询完整系统信息。

返回值 (SystemInfo):

字段类型说明
platformstring平台 ("ios" / "android")
brandstring设备品牌
modelstring设备型号
systemstring操作系统及版本
pixelRatiofloat像素比
screenWidth / screenHeightfloat屏幕尺寸 (px)
windowWidth / windowHeightfloat可用区域 (px)
safeAreaSafeArea安全区域信息
benchmarkLevelint性能等级 (Android)
SDKVersionstringSDK 版本
wifiEnabledboolWi-Fi 启用状态
environmentstring访问环境 ("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)

异步查询完整系统信息。

参数:

参数类型必须说明
onSuccessAction<SystemInfo>-成功回调
onFailAction<string>-失败回调
TudadaSDK.Instance.GetSystemInfo(
onSuccess: (info) => Debug.Log("平台: " + info.platform),
onFail: (err) => Debug.LogError(err)
);

GetWindowInfo()

同步查询窗口/屏幕尺寸及 SafeArea。

返回值 (WindowInfo):

字段类型说明
screenWidthfloat屏幕宽度 (px)
screenHeightfloat屏幕高度 (px)
windowWidthfloat可用区域宽度 (px)
windowHeightfloat可用区域高度 (px)
safeAreaSafeArea安全区域信息
WindowInfo windowInfo = TudadaSDK.Instance.GetWindowInfo();
Debug.Log("SafeArea top: " + windowInfo.safeArea.top);
Debug.Log("屏幕尺寸: " + windowInfo.screenWidth + " x " + windowInfo.screenHeight);

GetAppBaseInfo()

同步查询应用/SDK 基本信息。

返回值 (AppBaseInfo):

字段类型说明
SDKVersionstringSDK 版本
themestring主题
environmentstring访问环境 ("prod" / "dev")
AppBaseInfo appInfo = TudadaSDK.Instance.GetAppBaseInfo();
Debug.Log("SDK版本: " + appInfo.SDKVersion);
Debug.Log("主题: " + appInfo.theme);
Debug.Log("环境: " + appInfo.environment); // "prod" 或 "dev"

GetDeviceInfo()

同步查询设备硬件信息。

返回值 (DeviceInfo):

字段类型说明
brandstring设备品牌
modelstring设备型号
DeviceInfo deviceInfo = TudadaSDK.Instance.GetDeviceInfo();
Debug.Log("品牌: " + deviceInfo.brand);
Debug.Log("型号: " + deviceInfo.model);

GetMenuButtonBoundingClientRect()

同步查询菜单按钮位置。用于 UI 布局。

返回值 (MenuButtonRect):

字段类型说明
topfloat顶部位置
rightfloat右侧位置
bottomfloat底部位置
leftfloat左侧位置
widthfloat宽度
heightfloat高度
MenuButtonRect rect = TudadaSDK.Instance.GetMenuButtonBoundingClientRect();
Debug.Log("菜单按钮位置: top=" + rect.top + ", right=" + rect.right);