import ScreenResize from "../ScreenResize"; import { UIManager } from "../UIManager"; const { ccclass, property } = cc._decorator; @ccclass("SwitchPositionObj") export class SwitchPositionObj { @property({ type: cc.Node }) public UI: cc.Node = null; @property({ type: cc.Vec2/*, visible: function (this: ImageGroup) { return this.Reset; } */ }) public Pos: cc.Vec2[] = []; public SetPos(obj: cc.Node, posNum: cc.Vec2): void { obj.setPosition(posNum); } } @ccclass export default class SwitchPositionGroupExtra extends cc.Component { @property({ displayName: "改變座標群組", type: SwitchPositionObj }) public PosGroups: SwitchPositionObj[] = []; public Run(param: any[] = null): void { if (this.PosGroups != null && this.PosGroups.length) { for (let group of this.PosGroups) { cc.log("橫直轉換:" + group.UI.name + ":" + group.Pos[ScreenResize.IsPortrait]); group.SetPos(group.UI, group.Pos[ScreenResize.IsPortrait]); } } } onLoad() { UIManager.DireEvent.AddCallback(this.Run, this); this.Run(); } }