修复WASM路径解析问题,支持Cocos Creator环境 - 改进多路径WASM加载策略 - 添加Core.disableWasm()方法 - 简化WASM初始化逻辑以避免环境兼容性问题
This commit is contained in:
23
src/Core.ts
23
src/Core.ts
@@ -186,15 +186,36 @@ export class Core {
|
||||
* 如果实例已存在,则返回现有实例。
|
||||
*
|
||||
* @param debug - 是否为调试模式,默认为true
|
||||
* @param options - 额外的配置选项
|
||||
* @returns Core实例
|
||||
*/
|
||||
public static create(debug: boolean = true): Core {
|
||||
public static create(debug: boolean = true, options?: { disableWasm?: boolean }): Core {
|
||||
if (this._instance == null) {
|
||||
this._instance = new Core(debug);
|
||||
|
||||
// 如果指定禁用WASM,设置静默模式
|
||||
if (options?.disableWasm) {
|
||||
this.disableWasm();
|
||||
}
|
||||
}
|
||||
return this._instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁用WASM支持
|
||||
*
|
||||
* 当WASM加载失败或在不支持的环境中使用时调用。
|
||||
* 这将使ECS系统使用JavaScript回退实现。
|
||||
*/
|
||||
public static disableWasm(): void {
|
||||
// 动态导入WASM实例并设置为静默模式
|
||||
import('./Utils/Wasm/instance').then(({ ecsCore }) => {
|
||||
ecsCore.setSilent(true);
|
||||
}).catch(() => {
|
||||
// 如果导入失败,忽略错误
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册全局管理器
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user