搜索了一下,之前好像用的是 cc.sys.platform
但是3.2好像没这个了
那么3.2怎么判断
搜索了一下,之前好像用的是 cc.sys.platform
但是3.2好像没这个了
那么3.2怎么判断
export class PlatformJudge {
//oppo 小游戏
static get isOppo(): boolean {
return window.qg && window.qg.setLoadingProgress && !window.hbs && typeof (mz_jsb) == "undefined";
}
//vivo小游戏
static get isVivo(): boolean {
return window.qg && !window.qg.setLoadingProgress && !window.hbs && typeof (mz_jsb) == "undefined";
}
//魅族小游戏
static get isMZ(): boolean {
return typeof (mz_jsb) != "undefined";
}
//qq小游戏
static get isQQ(): boolean {
return window.qq;
}
//微信小游戏
static get isWX(): boolean {
return window.wx && !window.qq && !window.tt;
}
//是否是微信小游戏调试器
static get isWXDev(): boolean {
if (PlatformJudge.isWX) {
const { brand } = window.wx.getSystemInfoSync();
return brand == 'devtools';
}
return false;
}
//头条小游戏
static get isTT(): boolean {
return window.tt;
}
//华为小游戏
static get isHW(): boolean {
return window.hbs;
}
static get isBD(): boolean {
return window.swan;
}
//是否很严格
static get isStrict(): boolean {
// return true;
return PlatformJudge.isTT;
}
static getPlatformName(): string {
if (PlatformJudge.isWX)
return 'wx';
else if (PlatformJudge.isOppo)
return 'oppo';
else if (PlatformJudge.isVivo)
return 'vivo';
else if (PlatformJudge.isMZ)
return 'mz'
else if (PlatformJudge.isQQ)
return 'qq';
else if (PlatformJudge.isTT)
return 'tt';
else if (PlatformJudge.isHW)
return 'hw';
else if (PlatformJudge.isBD)
return 'bd';
return 'dev';
}
}
globalThis.PlatformJudge = PlatformJudge;
这个代码完全脱离了引擎。就算拿到Laya里,我觉得应该也能跑的起来。