Search Unity

Observables - Attach a UnityEvent to the the assignment of any variable

Discussion in 'Assets and Asset Store' started by homanicsjake, Jun 8, 2021.

  1. homanicsjake

    homanicsjake

    Joined:
    Feb 18, 2019
    Posts:
    15
    Observables Version 0.1.0.

    Attach a UnityEvent to a float, string, reference, or a custom class which will fire upon the assignment of the variable!



    With this Asset you will be able to create a strong game system which can easily be understood from within the Unity Editor. Heavily inspired by the observer pattern, this Asset can decouple and attach from/to other code bases in magnificent ways. Since the foundation of the scripts follow good programming practices/techniques, the rest of your code will continue to be clean through a trickle down effect (You only need ONE script In order to display ANY Observable's value). Although not fully implemented yet, file management follows a similar procedure (One script for saving/loading).

    Pros:
    • Utilize the power of UnityEvents to save performance on Update calls.
    • Follows the Observer pattern which can allow for properly decoupled code.
    • Easily expand/modify the functionality of an Observable through the use of UnityEvents all from within the Editor (No recompilation needed!).
    • Expandable code base which can easily fit into your custom classes, MonoBehaviours, or other types of serializable script types.

    Cons:
    • Abstraction - making it important to reference your observables properly (similar difficulties introduced with c# dynamics).
    • Many GameObjects - To keep things organized you will likely have one observable per GameObject which can lead to an abundance of GameObjects.

    Planned Features:
    • Saving/Loading of Observable values
    • Advanced Float Calculations
    • Advanced String formatting
    • Editor tool to create an Observable class of a provided type and a UnityEvent class associated with the newly created Observable.

    I have used variations of the Observables in my prototypes with much success. I have decided to create an Asset package for them. I would love any and all feedback.
     
    Last edited: Jun 8, 2021
  2. homanicsjake

    homanicsjake

    Joined:
    Feb 18, 2019
    Posts:
    15
    Download Observables 0.2.0!



    This addition adds file management! You are able to save and load values of Observables across play sessions!

    The prefab system in place may need some rework. Not sure of the best way to handle this...may need to create an editor window tool.

    As always, any feedback and suggestions are greatly appreciated!
     
    Rechronicle likes this.