Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[RELEASED] Event Manager - Configurable Pub/Subs Editor

Discussion in 'Assets and Asset Store' started by kennethDevelops, May 14, 2019.

  1. kennethDevelops

    kennethDevelops

    Joined:
    Jul 25, 2015
    Posts:
    13
    Hey! So, I've been using this for a while in my studio's 2 year game project, and with time I've improved it as much as I could. Today I can finally release it to the public!



    EventManager is a tool that helps you ensure communication between the elements on your game logic. In other words, it makes it easier to notify events to your GameObjects making use of the pub/sub (or Observer) pattern.

    For example, when the game is over, you want to notify every enemy to stop attacking the player. With EventManager, you can simply trigger the event"OnGameOver" and every element in the game that is subscribed to this event (in this case, the enemies) will be notified and react accordingly.

    Get it now in the Asset Store!

    There are no tricky things you have to do before using this asset, just import the Package and you're ready to go! All you need to know is in this short 14 min tutorial:



    If you want to know more, you can check out the online documentation


    Thank you for reading!
    Kenneth



    More at kennethdevelops.com | Support: kennethdevelops.com/support | Twitter: @KennethDevelops

    Assetstore: https://assetstore.unity.com/publishers/39204
     
  2. kennethDevelops

    kennethDevelops

    Joined:
    Jul 25, 2015
    Posts:
    13
    Here are some screenshots of the Configuration Window:





    As a programmer, I tried to make it as easy and simple as possible to trigger, subscribe and unsubscribe. Here are some screenshots of all the code needed to do so.

    Publish/Trigger event:

    Code (CSharp):
    1. //without parameters
    2. new DefinedEvent("EventId").Trigger();
    3.  
    4. //with parameters
    5. new DefinedEvent("EventId").SetIntParameter("parameterId", 105).Trigger();
    Subscribe to event:

    Code (CSharp):
    1. //Can be anywhere, Start(), Update() or literally anywhere
    2. void Awake(){
    3.     EventManager.SubscribeToEvent("EventId", ExampleCallbackFunc);
    4. }
    5.  
    6. //callback function MUST receive a DefinedEvent object
    7. private void ExampleCallbackFunc(DefinedEvent definedEvent){
    8.  
    9. }
    Unsubscribe to event:

    Code (CSharp):
    1. //Has to be after it has been subscribed, otherwise it will throw a warning.
    2. //But never an Exception
    3. void Start(){
    4.     EventManager.UnsubscribeToEvent("EventId", ExampleCallbackFunc);
    5. }
    You can get it now on the Asset Store!

    If you got this far, please tell me what you think and what could be improved in future updates.


    Thank you for reading!
    Kenneth



    More at kennethdevelops.com | Support: kennethdevelops.com/support | Twitter: @KennethDevelops

    Assetstore: https://assetstore.unity.com/publishers/39204