⚛️
UniFlux
  • Introduction
  • ❓Getting Started
    • What is UniFlux
    • Setup
  • 🧩Components
    • MonoFlux
    • MethodFluxAttribute
    • StateFluxAttribute
    • Extension Key
  • ⚠️Use Cases
    • Service Locator Alternative
    • Singleton Alternative
    • Messaging Alternative
    • Avoiding Prop Drilling
  • 📚Tutorials
    • How to use a custom Key?
    • How To See Subscriptions ?
    • 📽️(Video) How to Use UniFlux on Unity
  • Links and References
    • 🔗References
    • 🌍Unity Asset Store
    • 🎲Made With UniFlux
    • 📦Github
    • 😎About Me
Powered by GitBook
On this page
  • Install UniFlux
  • Generate your Scritps
Edit on GitHub
  1. Getting Started

Setup

Last updated 8 months ago

Install UniFlux

  • You can Download at

  • You can use the .unityPackage in releases

  • You can use the *.tzg in releases and add in PackageManager

  • You can add in PackageManager ()

https://github.com/xavierarpa/UniFlux.git
  • You can install via openupm CLI

openupm add com.xavierarpa.uniflux
  • You can install via npm

npm i com.xavierarpa.uniflux

Generate your Scritps

using UniFlux;
using UnityEngine;

public class Test : MonoFlux
{
    private void Start()
    {
        // Allows you to call any method subscribe with "0" Key
        "0".Dispatch();
    }
    [MethodFlux("0")] private void Tester()
    {
        Debug.Log("Hello world");
    }
}
using UniFlux;
using UnityEngine;

public class Test_2 : MonoFlux
{
    [MethodFlux("0")] private void Tester_2()
    {
        Debug.Log("Hello world 2");
    }
}

You can put both in a scene and see if they both receive the event

That's all !

Here another sample making subscriptions manually

using UniFlux;
public class Test : MonoBehaviour
{
  private void Start()
  {
    "KEY".Dispatch();
  }
  private void OnEnable() 
  { 
      "KEY".Store(true, OnExampleMethodIsCalled)
  }
  private void OnDisable() 
  { 
      "KEY".Store(false, OnExampleMethodIsCalled)
  }
  private void OnExampleMethodIsCalled()
  {
    Debug.Log("Hello World");
  }
}

public class Test_2 : MonoBehaviour
{
    private void OnEnable() 
    { 
      "KEY".Store(true, Tester_2)
    }
    private void OnDisable() 
    { 
      "KEY".Store(false, Tester_2)
    }
    private void Tester_2()
    {
      Debug.Log("Hello world 2");
    }
}
❓
Unity Asset Store
How to install package from git URL