35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
|
import ScreenResize from "../ScreenResize";
|
||
|
|
||
|
const { ccclass, property } = cc._decorator;
|
||
|
@ccclass("SwitchUIGroup")
|
||
|
export class SwitchUIGroup {
|
||
|
@property({ type: cc.Node })
|
||
|
public UI: cc.Node = null;
|
||
|
@property({ type: cc.Integer/*, visible: function (this: ImageGroup) { return this.Reset; } */ })
|
||
|
public SourceID: number[] = [];
|
||
|
|
||
|
public Set(obj: cc.Node, switchObj: cc.Node): void {
|
||
|
if (obj == null || switchObj == null) {
|
||
|
return;
|
||
|
}
|
||
|
obj.removeAllChildren();
|
||
|
obj.ExAddChild(switchObj);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@ccclass
|
||
|
export default class SwitchSoueceGroup extends cc.Component {
|
||
|
@property({ displayName: "換UI群組", type: SwitchUIGroup })
|
||
|
public UIGroups: SwitchUIGroup[] = [];
|
||
|
public Run(switchObg: cc.Node): void {
|
||
|
if (this.UIGroups != null && this.UIGroups.length) {
|
||
|
for (let group of this.UIGroups) {
|
||
|
let child: cc.Node[] = switchObg.getChildByName(group.SourceID[ScreenResize.IsPortrait].toString()).children;
|
||
|
for (let i: number = 0; i < child.length; i++) {
|
||
|
group.Set(group.UI, child[i]);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|