Kaynağa Gözat

Merge pull request #2800 from nobook/feature/add-unregsiterAction-api

add unregisterAction API in ActionManager
David Catuhe 8 yıl önce
ebeveyn
işleme
7a5e8814b9
1 değiştirilmiş dosya ile 19 ekleme ve 0 silme
  1. 19 0
      src/Actions/babylon.actionManager.ts

+ 19 - 0
src/Actions/babylon.actionManager.ts

@@ -319,6 +319,25 @@
         }
 
         /**
+         * Unregisters an action to this action manager
+         * @param {BABYLON.Action} action - the action to be unregistered
+         * @return {Boolean}
+         */
+        public unregisterAction(action: Action): Boolean {
+            var index = this.actions.indexOf(action);
+            if (index !== -1) {
+                this.actions.splice(index, 1);
+                ActionManager.Triggers[action.trigger] -= 1;
+                if (ActionManager.Triggers[action.trigger] === 0) {
+                    delete ActionManager.Triggers[action.trigger]
+                }
+                delete action._actionManager;
+                return true;
+            }
+            return false;
+        }
+
+        /**
          * Process a specific trigger
          * @param {number} trigger - the trigger to process
          * @param evt {BABYLON.ActionEvent} the event details to be processed