33 lines
983 B
TypeScript
33 lines
983 B
TypeScript
import ScreenResize from "../ScreenResize";
|
|
import { UIManager } from "../UIManager";
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass("SwitchSizeObj")
|
|
export class SwitchScaleObj {
|
|
@property({ type: cc.Node })
|
|
public UI: cc.Node = null;
|
|
@property({ type: cc.Float/*, visible: function (this: ImageGroup) { return this.Reset; } */ })
|
|
public ScaleNum: number[] = [];
|
|
|
|
public SetObjScale(obj: cc.Node, scaleNum: number): void {
|
|
obj.setScale(scaleNum);
|
|
}
|
|
}
|
|
@ccclass
|
|
export default class SwitchScaleGroupExtra extends cc.Component {
|
|
@property({ displayName: "縮放scale群組", type: SwitchScaleObj })
|
|
public ScaleGroups: SwitchScaleObj[] = [];
|
|
public Run(): void {
|
|
if (this.ScaleGroups != null && this.ScaleGroups.length) {
|
|
for (let group of this.ScaleGroups) {
|
|
group.SetObjScale(group.UI, group.ScaleNum[ScreenResize.IsPortrait]);
|
|
}
|
|
}
|
|
}
|
|
onLoad() {
|
|
UIManager.DireEvent.AddCallback(this.Run, this);
|
|
this.Run();
|
|
}
|
|
}
|