瀏覽代碼

Checking if functions are undefined

Now checking if these functions are defined before firing them.
Jordan Kintzle 4 年之前
父節點
當前提交
837f3ef258
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6 2
      gui/src/2D/controls/toggleButton.ts

+ 6 - 2
gui/src/2D/controls/toggleButton.ts

@@ -109,9 +109,13 @@ export class ToggleButton extends Rectangle {
 
         // Update the visual state based on the new value
         if (this._isActive) {
-            this.toActiveAnimation();
+            if (this.toActiveAnimation) {
+                this.toActiveAnimation();
+            }
         } else {
-            this.toInactiveAnimation();
+            if (this.toInactiveAnimation) {
+                this.toInactiveAnimation?.();
+            }
         }
 
         this._markAsDirty();