Search Unity

[Open Source] inFluent - A Fluent API extension

Discussion in 'Assets and Asset Store' started by garrido86, Aug 14, 2016.

  1. garrido86

    garrido86

    Joined:
    Dec 17, 2013
    Posts:
    233
    Hey guys, I recently had developed a desire of a fluent API for GameObjects where you can simply chain methods with ease. Sadly there where as far I am concerned none, so I went there and started inFluent as a side project.

    https://github.com/rubit0/inFluent

    The readme on the GitHub page explains pretty much everything but let me show you one example which is my personal favorite: Attaching Components while changing it's properties and invoking methods with a simple lambda!

    Code (CSharp):
    1.     this.gameObject.AttachComponent<AudioSouce>((r, c) =>
    2.                     {
    3.                         if(r)
    4.                         {
    5.                             c.clip = AmbientMusic;
    6.                             c.loop = true;
    7.                             c.volumen = StartAudioSound;
    8.                             c.Play();
    9.                         }
    10.                     });
    What do you guys think?