@cc-component/cc-ex-component 1.7.7 → 1.7.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -171,6 +171,16 @@ declare module 'cc' {
171
171
  * 确保组件存在 不存在则添加
172
172
  */
173
173
  ensureComponent<T extends Component>(className: string): T;
174
+
175
+
176
+ }
177
+ interface Button {
178
+ /**
179
+ * 禁用按钮
180
+ * @param enable
181
+ * @param time 禁用后xx秒后恢复,不传一直禁用
182
+ */
183
+ enable(enable: boolean, time?: number): void;
174
184
  }
175
185
 
176
186
  interface Animation {
@@ -642,6 +652,25 @@ Node.prototype.enable = function (this: Node, enable: boolean, time?: number): v
642
652
  }
643
653
  };
644
654
 
655
+ Button.prototype.enable = function (this: Button, enable: boolean, time?: number): void {
656
+ if (this.isValid) {
657
+ const btn = this
658
+ if (btn) {
659
+ if (time) {
660
+ btn.interactable = enable;
661
+ if (!enable) {
662
+ setTimeout(() => {
663
+ if (btn && btn.isValid)
664
+ btn.interactable = true;
665
+ }, time)
666
+ }
667
+ } else {
668
+ btn.interactable = enable;
669
+ }
670
+ }
671
+ }
672
+ };
673
+
645
674
  Node.prototype.touchStartAnim = function (this: Node, scale?: number, time?: number): void {
646
675
  if (this.isValid) {
647
676
  const btn = this
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cc-component/cc-ex-component",
3
- "version": "1.7.7",
3
+ "version": "1.7.8",
4
4
  "engine": ">=3.8.6",
5
5
  "description": "系统组件添加常用扩展方法",
6
6
  "main": "index.ts",