Subscribing To A Brain
Once the Tool and Parameter attributes are set up, Subscribe and Unsubscribe to any Brain in your scene.
Create An Instance Of A Brain
A brain is a scriptable object, so create an instance of that scriptable object in your project folder.
(Hint* there can be more than one instance of a brain in any given project 😄)
Right-click in the project folder, go to Create -> Indie -> Brain

This should create the brain with a System Message, Message History, and Context.
(Hint* Add a system message to give the brain character and guidelines of how to interact with the player 🧠)

Reference A Brain
public Brain brain;Subscribe
Subscribe this script to the brain to be analyzed for tools.
private void OnEnable()
{
    brain?.RegisterScript(GetType(), this);
}Unsubscribe
Unsubscribe this script from the brain when the script no longer needs to be considered by the brain.
private void OnDisable()
{
    brain?.UnRegisterScript(GetType());
}Full Example Code
using UnityEngine;
using Indie.Attributes;
public class MyGameController : MonoBehaviour
{
    public Brain brain;
    
    private void OnEnable()
    {
        brain?.RegisterScript(GetType(), this);
    }
    
    private void OnDisable()
    {
        brain?.UnRegisterScript(GetType());
    }
    [Tool("MovePlayer", "Move the player to a specified position.")]
    [Parameter("position", "Position to move the player to.")] 
    public void MovePlayer(Vector3 position)
    {
        // Method implementation
    }
    // Other methods...
}Last updated