I ran into the following issue using the Action Manager:
If two registered actions run, and 1 action deletes an action from the list. Then depending on the order of the actions, the actions registered past the one getting deleted, get skipped, regardless of them being deleted or not. I’m guessing because there is an internal array it’s iterating through, and the deletion is causing the index to get “offset”.
I’m not sure if this would be considered a bug, how would one go around this in a clean way?
Maybe a solution would be to keep a copy of the list of the actions before it goes through all the actions, and when we go over one we compare if it’s deleted or not. This way this issue would be avoided.
The issue here is, as you also said, the array iteration. Removing an object from an array while iterating this array will result in exactly this behavior. One solution for that is to call remove in the next frame. For example:
Due to back-compat (and the fact that I wouldn’t consider this a bug) we can’t change the behavior, but I will be happy to discuss it internally with the team and see if we want to change the unegister Action function to support this. CC @Deltakosh