# Setup

### Install UniFlux

* You can Download at [Unity Asset Store](https://assetstore.unity.com/packages/slug/250332)
* You can use the *.unityPackage* in releases
* You can use the \*.tzg in releases and add in PackageManager
* You can add in PackageManager ([How to install package from git URL](https://docs.unity3d.com/Manual/upm-ui-giturl.html))

```bash
https://github.com/xavierarpa/UniFlux.git
```

* You can install via openupm CLI

```bash
openupm add com.xavierarpa.uniflux
```

* You can install via npm

```bash
npm i com.xavierarpa.uniflux
```

### Generate your Scritps

{% code lineNumbers="true" fullWidth="true" %}

```csharp
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");
    }
}
```

{% endcode %}

{% code fullWidth="true" %}

```csharp
using UniFlux;
using UnityEngine;

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

{% endcode %}

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

That's all !

Here another sample making subscriptions manually

{% code fullWidth="true" %}

```csharp
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");
    }
}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xavierarpa.gitbook.io/uniflux/getting-started/setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
