32 lines
931 B
TypeScript
32 lines
931 B
TypeScript
|
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();
|
||
|
}
|
||
|
}
|