fix: 修复图集GC回收和天赋图标加载异常问题
1. 为uicons图集增加引用计数防止被GC回收导致spriteFrames为空 2. 增加图集spriteFrames存在性校验,避免空引用报错 3. 将天赋图标配置转为字符串类型,防止纯数字配置导致获取失败
This commit is contained in:
@@ -292,6 +292,8 @@ export class SingletonModuleComp extends ecs.Comp {
|
||||
preloadCommonAssets() {
|
||||
resources.load("gui/uicons", SpriteAtlas, (err, atlas) => {
|
||||
if (!err && atlas) {
|
||||
// 增加引用计数,防止图集被引擎自动垃圾回收(GC)导致底层 spriteFrames 为 null
|
||||
atlas.addRef();
|
||||
this.uiconsAtlas = atlas;
|
||||
} else {
|
||||
mLogger.error(this.debugMode, 'SMC', "预加载 gui/uicons 图集失败:", err);
|
||||
|
||||
Reference in New Issue
Block a user