Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[RELEASED] Super Invoke - A simple framework to time-control your code

Discussion in 'Assets and Asset Store' started by JacobGames, Feb 2, 2016.

  1. JacobGames

    JacobGames

    Joined:
    Dec 2, 2015
    Posts:
    12
    Hello,


    Check out our first asset Super Invoke forum-banner.jpg


    Super Invoke allows you to easily delay any piece of code in your games.






    WHY SUPER?
    You can think of Super Invoke as an enhanced version of the standard MonoBehaviour Invoke method.
    The standard Invoke method can only delay parameterless methods. It uses magic strings too. You also have to write several lines of code and use Coroutines in order to delay parameterized methods.



    DELAY ANY METHOD
    Super Invoke lets you easily delay in one line of code:
    • parameterless methods
    • parameterized methods


    USE SEQUENCES
    Create sequences with methods and delays that will help you manage any kind of complex operations. Sequences can help you build and control your animations from scripts.




    Free from MonoBehaviour
    Super Invoke can be used in any type of class, whereas the standard Invoke method and Coroutines can only be used in MonoBehaviours.


    No magic string
    You can safely rename your delayed methods because Super Invoke does not use magic strings. It works with actions.


    Use it everywhere
    Super Invoke works with any Unity version and any common deployment platforms. It has been fully tested on mobile platforms.




    FAST LINKS
     
    Last edited: Sep 28, 2016
  2. JacobGames

    JacobGames

    Joined:
    Dec 2, 2015
    Posts:
    12
    Super Invoke 2.0 has been released!

    NEW FEATURE: REPEATS
    You can now repeat methods with parameters, parameterless methods and sequences too.

    5 - Repeat Methods.jpg
    6 - Repeat sequences.jpg

    As for the number of repeats, you may also choose to repeat ad infinitum.



    IMPROVEMENTS
    We added new overloads of the Run method giving the possibility to choose the position of the parameters, E.G. some users prefer to write SuperInvoke.Run(action, delay), other users prefer to write Run(delay, action).

    We have extensively worked on improving the internal functioning of Super Invoke, which is now faster and it produces close to zero bytes of garbage, thanks to a new internal pooling system and several optimizations.


    Feel free to contact us about any kind of subject, we have received many feedbacks from users that helped improve Super Invoke. Thanks!
     
  3. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Seem a nice library, but no sources. :rolleyes:
     
  4. JacobGames

    JacobGames

    Joined:
    Dec 2, 2015
    Posts:
    12
    ZJP, we would like to satisfy more. Many users are very happy with Super Invoke, they're using it as a core component in their projects. Others have asked about the source rightly because it is such a core component in the project.

    Since its characteristics we have seen that it will be beneficial to everybody to offer the source code for free it in the next update. It will be live on the asset store in the next few days. There will be a new feature and many optimizations.
     
  5. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Very good news. Thanks for the reply. :cool:
     
  6. JacobGames

    JacobGames

    Joined:
    Dec 2, 2015
    Posts:
    12
    Super Invoke 2.1 is live on the Asset Store!

    SOURCE CODE
    If you update now you will get the full source code for free!



    NEW FEATURE: SkipFrames


    You can now specify an arbitrary number of frames after which the action is called. It's basically about delaying a method call waiting frames instead of seconds.

    Additionally, the internal pooling system has been further improved.



    In the meantime we are working for a big 3.0 update with tons of new features and improvements. Stay tuned!
     
    Last edited: Nov 14, 2016
  7. JacobGames

    JacobGames

    Joined:
    Dec 2, 2015
    Posts:
    12
    Super Invoke 3.0 has been released!

    NEW FEATURES
    Job and JobRepeat objects: from now on each execution of methods Run and RunRepeat returns an object that offers job-specific features (a job is anything that has been delayed; sequences too).

    • job.OnComplete - a useful callback to be notified when the job has been completed.
    • job.Pause - pauses the job
    • job.Resume - resumes a paused job
    • job.Kill - kills the job

    • job.KillOnDestroy - automatically kills the job when the game object is destroyed
    • job.PauseOnDisable - automatically pauses the job when the game object is disabled, and by default, it automatically resumes the job when the game objects is re-enabled.

    JobRepeat objects offer additional features related to repeating jobs.

    We have also greatly simplified the overall tagging process.
     
    ZJP likes this.
  8. ikemen_blueD

    ikemen_blueD

    Joined:
    Jan 19, 2013
    Posts:
    340
    @JacobGames Very interesting system. I know Super-Invoke wins Unity coroutine on sequence logic. What about a delay logic, how is the Super-Invoke performance compare to Unity coroutine, in terms of cpu cost, memory usage? Can Super-Invoke call a Coroutine, or I have to replace all my coroutines to normal functions, and use Super-Invoke to call them? You mention about Jobs & internal Pooling system, so does that means 1 Manager to handle all super-invokes and re-use if possible? Can you further explain how Super-Invoke improves its overall performance? Many thanks, sorry for lots of questions :)
     
  9. JacobGames

    JacobGames

    Joined:
    Dec 2, 2015
    Posts:
    12
    @ikemen_blueD
    Yes, Super Invoke is quite efficient and allows you to focus on your methods instead of being imposed (see coroutines) of writing some method that returns IEnumerator with yield and WaitForSeconds statements which just make your methods more tiresome to write and less pure, so to say.

    You're right, there's one manager that has control over all the delays invoked throughout the project.
    In terms of cpu cost, on a few delays Super Invoke has the same performances of coroutines and because of its internal pooling system, the more you use it the less it costs you, which makes it more efficient than coroutines. Memory usage is slightly more than coroutines, but as cpu the more it's used the more it's efficient.

    Super Invoke can call coroutines, so you don't need to rewrite them :)

    The pooling system works with internal objects. Whenever you delays something, a piece of code, a method or a sequence, the pooling systems creates the internal objects that need to be created so that the delay can be executed. When the delay is executed, the pooling system caches the internal objects. When you subsequently delay new methods, the pooling systems will not create new objects, but it will reuse the cached ones so that it uses less cpu and less memory.

    It's like, instead of instantiating gameobjects, you cache them and deactivate them, and subsequently activate them instead of instantiating new ones.
     
    ikemen_blueD likes this.
  10. ikemen_blueD

    ikemen_blueD

    Joined:
    Jan 19, 2013
    Posts:
    340
    Very flexible workflow. I'm surprised that I don't need to change my coroutine code-base. Going to purchase your pack soon, scared u may increase your price soon lol
     
  11. ikemen_blueD

    ikemen_blueD

    Joined:
    Jan 19, 2013
    Posts:
    340
    @JacobGames hi guys, so far I did some quick tests on Super-Invoke. Its runtime performance is awesome, very low ms & 0 runtime memory allocations. But, its initial impact is huge. For 1 repeated invoke, calling 1 empty method, Super-Invoke takes around 2 ms & 80 bytes, probably to initialize its internal pool. And, the initial cost increases with the number of invokes jobs, for 1000 invokes, calling an empty method, it takes around 78.1 KB and 3.14 ms. Any thoughts on improvement its initialization process :)
     
  12. JacobGames

    JacobGames

    Joined:
    Dec 2, 2015
    Posts:
    12
    @ikemen_blueD actually yes, we do have thought about an alternative and improved initialization process. Currently, the Super Invoke manager GO and internal pooling system is self-instantiated the first time you use SuperInvoke in your code, that's the reason for the initial cost.

    We could change that and give you the possibility to choose to initialize and instantiate the manager as soon as the scene starts, so that when you use SuperInvoke in your code, the first call won't have any cost impact.

    We're gonna release it in the next update. I will notify you when it'll be online, or I can also send you the package before it goes live so you won't have to wait the Asset Store Team review time.
     
    ikemen_blueD likes this.
  13. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    Interesting asset. Does SuperInvoke also allocates 9 bytes like coroutines when running a delayed method?
     
  14. JacobGames

    JacobGames

    Joined:
    Dec 2, 2015
    Posts:
    12
    Hey silentneedle , absolutely not. SuperInvoke has zero runtime memory allocation. It will only need to allocate when it is initialized and when the internal pooling system needs more objects, which makes it efficient because the more you use SuperInvoke the less it will need to allocate.
     
    silentneedle likes this.
  15. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    Thanks, that's awesome.

    Could you do me a favour and add a toggle for

    Code (CSharp):
    1. private void Awake() {
    2.             DontDestroyOnLoad(gameObject);
    3. }
    in your next update?

    I prefer to add all my singletons to a parent game object. When doing that DontDestroyOnLoad complains about not being in the root of the hierarchy.
     
  16. JacobGames

    JacobGames

    Joined:
    Dec 2, 2015
    Posts:
    12

    Of course we can do it. We actually should have thought about it before.
    Thanks for using Super Invoke, I hope it is helping you greatly!
     
    silentneedle likes this.
  17. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    Thank you. So far your asset is a blast. Our code looks much tidier now.
     
    JacobGames likes this.
  18. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    It seems there is a small chance SuperInvoke gets instantiated too late when calling it the first time. Unfortunately I'm not able to reproduce it.
     
  19. JacobGames

    JacobGames

    Joined:
    Dec 2, 2015
    Posts:
    12
    silentneedle what do you mean with 'too late'? The first time you call any method, Super Invoke must initialize its internal structure as if it's not initialized it cannot execute any operation.

    We have just pushed a new update which is highly related to your requests.
    It adds an optional init method that let's you control when you want SuperInvoke to be initialized (so you control when its necessary initial memory allocation operations are executed) plus it allows you to choose whether the Super Invoke manager object will be flagged with DontDestroyOnLoad.


    We're also soon publish a new update with additional internal pool optimizations. We'll also add an API that will let you choose the size and the initial count of the internal pool so that you can allocate what your game needs and, depending on the pool parameter, possibly never create any garbage.
     
  20. YuriyVotintsev

    YuriyVotintsev

    Joined:
    Jun 11, 2013
    Posts:
    91
    It will be great to have an ability to delay not only by time and frames, but also by some condition.
    Something like:
    sequence.AddDelay(()=>SomeInt == 10);
    Or more clear:
    sequnce.WaitUntil(()=>SomeInt == 10);
    sequnce.WaitWhile(()=>SomeInt != 10);

    And one more suggestion to integrate work with coroutines:
    sequence.WaitForCoroutine(SomeCoroutine());
    And
    SuperInvoke.StartCoroutine(SomeCoroutine());
    to use coroutines in non MonoBehaviour classes.