28 lines
949 B
TypeScript
28 lines
949 B
TypeScript
import { _decorator, Component, Node } from 'cc';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('ToggleListButton')
|
|
export class ToggleListButton extends Component {
|
|
// Ссылка на узел списка, который нужно показать или скрыть
|
|
@property(Node)
|
|
public equipmentList: Node = null!;
|
|
|
|
// Флаг состояния списка (активен/не активен)
|
|
private isListActive: boolean = false;
|
|
|
|
onLoad() {
|
|
// При загрузке сцены скрываем узел списка
|
|
if (this.equipmentList) {
|
|
this.equipmentList.active = false;
|
|
}
|
|
}
|
|
|
|
// Метод, который нужно вызвать при клике на кнопку
|
|
eventClick() {
|
|
if (this.equipmentList) {
|
|
this.isListActive = !this.isListActive;
|
|
this.equipmentList.active = this.isListActive;
|
|
}
|
|
}
|
|
}
|