32 lines
931 B
TypeScript
Raw Normal View History

2022-08-26 16:48:17 +08:00
import ScreenResize from "../ScreenResize";
import { UIManager } from "../UIManager";
const { ccclass, property } = cc._decorator;
@ccclass("SwitchWHObj")
export class SwitchWHObj {
@property({ type: cc.Node })
public UI: cc.Node = null;
@property({ type: cc.Vec2/*, visible: function (this: ImageGroup) { return this.Reset; } */ })
public WH: cc.Vec2[] = [];
public SetWH(obj: cc.Node, WHNum: cc.Vec2): void {
obj.SetSizeDelta(WHNum);
}
}
@ccclass
export default class SwitchWHGroupExtra extends cc.Component {
@property({ displayName: "改變寬高群組", type: SwitchWHObj })
public WHGroups: SwitchWHObj[] = [];
public Run(): void {
if (this.WHGroups != null && this.WHGroups.length) {
for (let group of this.WHGroups) {
group.SetWH(group.UI, group.WH[ScreenResize.IsPortrait]);
}
}
}
onLoad() {
UIManager.DireEvent.AddCallback(this.Run, this);
this.Run();
}
}