perf(talent): 优化天赋系统的图集预加载与缓存逻辑
将天赋图集预加载从天赋界面初始化时提前至游戏公共资源加载阶段,新增全局单例缓存机制替换组件自身的静态缓存,移除冗余的异步加载代码与未使用的导入语句,修正TalentItemComp的初始默认天赋类型为Attack
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
* - ScoreWeights(ScoreSet)—— 得分权重配置
|
||||
* - GameEvent.MissionEnd / MissionStart —— 游戏生命周期事件
|
||||
*/
|
||||
import { _decorator, Node, Label, Button, ProgressBar, instantiate, Prefab, resources, SpriteAtlas } from "cc";
|
||||
import { _decorator, Node, Label, Button, ProgressBar, instantiate, Prefab } from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { mLogger } from "../common/Logger";
|
||||
@@ -88,20 +88,8 @@ export class TalentsComp extends CCComp {
|
||||
}
|
||||
|
||||
onAdded(args: any) {
|
||||
// 先立刻刷新界面结构,保证面板秒开
|
||||
// 直接刷新界面,因为图集已经在游戏启动时被 smc 预加载并缓存
|
||||
this.refreshUI();
|
||||
|
||||
// 异步预加载图集,不阻塞主界面的生成
|
||||
resources.load("gui/uicons", SpriteAtlas, (err, atlas) => {
|
||||
if (!err && atlas) {
|
||||
TalentItemComp.setAtlas(atlas);
|
||||
// 图集加载完毕后,让所有的子组件只刷新一下自己的图标
|
||||
this.talents_content.children.forEach(child => {
|
||||
let comp = child.getComponent(TalentItemComp);
|
||||
if (comp) comp.refreshIcon();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** 刷新整体界面 */
|
||||
|
||||
Reference in New Issue
Block a user