perf(天赋面板): 优化天赋面板加载性能,减少重复资源加载
调整天赋面板预制体的UI布局参数,优化间距、内边距与容器尺寸。将天赋子项的图集加载改为父组件统一预加载并缓存,避免重复加载同一资源。面板添加时先立即刷新UI以保证秒开,后续异步更新所有子项的图标。
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
* - ScoreWeights(ScoreSet)—— 得分权重配置
|
||||
* - GameEvent.MissionEnd / MissionStart —— 游戏生命周期事件
|
||||
*/
|
||||
import { _decorator, Node, Label, Button, ProgressBar, instantiate, Prefab } from "cc";
|
||||
import { _decorator, Node, Label, Button, ProgressBar, instantiate, Prefab, resources, SpriteAtlas } 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,7 +88,20 @@ export class TalentsComp extends CCComp {
|
||||
}
|
||||
|
||||
onAdded(args: any) {
|
||||
// 先立刻刷新界面结构,保证面板秒开
|
||||
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