MatchMaster/assets/Script/module/Tool/RemoteAtlasBindings.ts

22 lines
699 B
TypeScript

import BlockAssetManager from "./BlockAssetManager";
const { ccclass, property } = cc._decorator;
/** 恢复预制体的默认小图(含未激活子节点),不覆盖业务已经设置的图片。 */
@ccclass
export default class RemoteAtlasBindings extends cc.Component {
@property([cc.Sprite])
sprites: cc.Sprite[] = [];
@property([cc.String])
frameKeys: string[] = [];
onLoad(): void {
this.sprites.forEach((sprite, index) => {
if (!sprite || sprite.spriteFrame) return;
const [atlas, name] = this.frameKeys[index].split("/");
sprite.spriteFrame = BlockAssetManager.instance.getAtlasFrame(atlas, name);
});
}
}