Publisher | Dev Dunk Studio |
---|---|
File size | 371.84kB |
Number of files | 5 |
Latest version | 1 |
Latest release date | 2022-04-28 09:02:15 |
First release date | 2022-04-28 09:02:15 |
Supported Unity versions | 2018.4.2 or higher |
Fast Invoke is an alternative to the MonoBehavior Invoke and InvokeRepeating.
Fast Invoke uses Tasks, to run your code asyncronously. This will be great for performance as well as make your code more flexible and modular!
Performance
MonoBehavior Invoke uses reflection (using the input string to search through all methods and select the right one) to call the desired method. This is very slow. Fast Invoke uses Actions as an alternative, which is a lot faster!
Even Better
Next to performance benefits, Fast Invoke also allows you to add any variable to the function being called (using generics). This way you can pass any variable you desire, so you don't have to rely on global variables for the variables used in the invoked method.
More Functionality
MonoBehavior Invoke just has Invoke and InvokeRepeating, which Fast Invoke also has (but improved). Next to this Fast Invoke also has InvokeMultiple and InvokeMultipleRepeated, so you can run the desired method multiple times from 1 line of code!
An great example use case would be spawning waves of enemies on a timer, which can easily be managed this way.