You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.1 KiB
50 lines
1.1 KiB
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class NodeFollowHidden extends cc.Component {
|
|
|
|
@property({
|
|
type: cc.Node,
|
|
displayName: "跟随节点"
|
|
})
|
|
followNodeList: cc.Node[] = [];
|
|
|
|
@property({
|
|
displayName: "是否反向跟随"
|
|
})
|
|
isReverseFollow: boolean = false;
|
|
|
|
@property({
|
|
displayName: "激活时是否触发"
|
|
})
|
|
useEnable: boolean = true;
|
|
|
|
@property({
|
|
displayName: "禁用时是否触发"
|
|
})
|
|
useDisable: boolean = true;
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
// onLoad () {}
|
|
|
|
// start() {}
|
|
|
|
protected onEnable(): void {
|
|
if (this.useEnable) {
|
|
for (const iterator of this.followNodeList) {
|
|
iterator.active = this.isReverseFollow ? !this.node.active : this.node.active;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected onDisable(): void {
|
|
if (this.useDisable) {
|
|
for (const iterator of this.followNodeList) {
|
|
iterator.active = this.isReverseFollow ? !this.node.active : this.node.active;
|
|
}
|
|
}
|
|
}
|
|
|
|
// update (dt) {}
|
|
}
|
|
|