import { _decorator, Component, Node } from 'cc'; const { ccclass, property } = _decorator; @ccclass('SkillLayerTop') export class SkillLayerTop extends Component { onEnable() { this.node.on(Node.EventType.CHILD_ADDED, this.onChildAdded, this); } protected onDisable(): void { this.node.off(Node.EventType.CHILD_ADDED, this.onChildAdded, this); } onChildAdded(child: Node) { //console.log("onChildAdded", child.name) let index = this.node.children.findIndex((item) => item.name == child.name) if (index != -1) { child.setSiblingIndex(index); } } }