跳到主要内容

Unity Editor 模拟

Unity Editor 模拟

无需 WebGL 构建即可在 Unity Editor 中测试所有 API。

工作方式

APIEditor 行为
Auth返回模拟登录码和用户信息
Storage使用 PlayerPrefs 模拟(键前缀:TudadaSDK_
TudadaStore使用 PlayerPrefs 模拟(键前缀:TudadaStore_
System返回 Unity 屏幕信息 + 默认值
Vibration输出控制台日志(无实际振动)
Keyboard输出控制台日志
Clipboard使用系统剪贴板
Ad立即返回成功响应,模拟观看完成
Accelerometer立即返回成功响应(加速度数据需手动触发)
Lifecycle输出控制台日志

Editor 中的 IsAvailable()

在 Editor 中 IsAvailable() 返回 false,但调用各 API 时会自动执行模拟行为。因此按以下方式编写代码即可在 Editor 和 WebGL 中均可运行:

// 在Editor中也以模拟方式运行
TudadaSDK.Instance.Login(
onSuccess: (result) => {
// Editor: 返回模拟码
// WebGL: 返回实际登录码
Debug.Log("码: " + result.code);
}
);