Skip to content

Adjust API Reference

The Adjust module API (IAdjustModule) provides programmatic access to register contexts, manage adjustable values, and extend the module with custom type adapters. Access it via Debby.Adjust.

Core Methods

NewContext

Creates a new runtime context using the builder pattern.

csharp
IContextBuilder NewContext(
    string name,
    GameObject gameObject = null,
    AdjustContextAttribute config = null
)

Parameters:

  • name: The display name for the context tab
  • gameObject (optional): GameObject to tie the context lifetime to (auto-unregisters when destroyed)
  • config (optional): Context configuration (icon, command prefix)

Returns: IContextBuilder for chaining value/action additions

Example:

csharp
using Debology.Debby;
using Debology.Debby.Modules.Adjust;
using Debology.Debby.Elements;
using UnityEngine;

public class RuntimeContextExample : MonoBehaviour
{
    private AdjustableValue<int> _score;
    private AdjustableValue<float> _timeScale;

    void Start()
    {
        _score = new AdjustableValue<int>(0);
        _timeScale = new AdjustableValue<float>(
            () => Time.timeScale,
            value => Time.timeScale = value
        );

        Debby.Adjust.NewContext("Game Settings", gameObject)
            .AddValue("Score", _score, new AdjustIntAttribute(min: 0, max: 9999))
            .AddValue("Time Scale", _timeScale, new AdjustFloatAttribute(
                min: 0f,
                max: 2f,
                pageSize: 0.1f,
                isSlider: true
            ))
            .AddAction("Reset Score", () => _score.Value = 0, new AdjustActionAttribute { Icon = DebbyIcon.Refresh })
            .Build();
    }
}

RegisterContext (Instance)

Registers an existing object instance as a context using attribute-based definitions.

csharp
void RegisterContext(
    object context,
    string name = null,
    GameObject gameObject = null,
    AdjustContextAttribute configOverride = null
)

Parameters:

  • context: The object instance containing [Adjust] attributes
  • name (optional): Context name (defaults to class name)
  • gameObject (optional): GameObject for automatic lifetime management
  • configOverride (optional): Override the class-level [AdjustContext] attribute

Example:

csharp
using Debology.Debby;
using Debology.Debby.Modules.Adjust.Attributes;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    [AdjustInt(min: 0, max: 100, isSlider: true)]
    public int Health = 100;

    [AdjustFloat(min: 0f, max: 20f)]
    public float Speed = 5f;

    [AdjustAction(icon: DebbyIcon.Refresh)]
    public void ResetStats()
    {
        Health = 100;
        Speed = 5f;
    }

    void Start()
    {
        // Register this instance
        Debby.Adjust.RegisterContext(this, "Player", gameObject);
    }

    void OnDestroy()
    {
        // Manual cleanup if not tied to GameObject
        // Debby.Adjust.UnregisterContext(this);
    }
}

RegisterContext<T> (Type)

Registers a context by type, creating a new instance automatically.

csharp
void RegisterContext<T>(
    string name = null,
    GameObject gameObject = null,
    AdjustContextAttribute configOverride = null
) where T : new()

Parameters:

  • name (optional): Context name (defaults to type name)
  • gameObject (optional): GameObject for automatic lifetime management
  • configOverride (optional): Override the class-level [AdjustContext] attribute

Example:

csharp
using Debology.Debby;
using Debology.Debby.Modules.Adjust.Attributes;

public class GameSettings
{
    [Adjust]
    public bool EnableCheats = false;

    [AdjustInt(min: 30, max: 144)]
    public int TargetFPS = 60;

    [AdjustAction]
    public void ApplySettings()
    {
        Application.targetFrameRate = TargetFPS;
    }
}

// Register from anywhere
void RegisterSettings()
{
    Debby.Adjust.RegisterContext<GameSettings>("Settings");
}

UnregisterContext (Instance)

Removes a context registered by instance.

csharp
void UnregisterContext(object context)

Parameters:

  • context: The instance previously registered

Example:

csharp
void OnDisable()
{
    Debby.Adjust.UnregisterContext(this);
}

UnregisterContext<T> (Type)

Removes a context registered by type.

csharp
void UnregisterContext<T>() where T : new()

Example:

csharp
void DisableSettings()
{
    Debby.Adjust.UnregisterContext<GameSettings>();
}

GetContext<T>

Retrieves the instance of a registered context.

csharp
T GetContext<T>() where T : class

Returns: The context instance, or null if not registered

Example:

csharp
using Debology.Debby;

void ModifySettings()
{
    var settings = Debby.Adjust.GetContext<GameSettings>();
    if (settings != null)
    {
        settings.TargetFPS = 120;
        settings.ApplySettings();
    }
}

Open

Opens the Adjust module in the Debby UI.

csharp
void Open()

Context Builder API

The IContextBuilder interface provides methods for building runtime contexts dynamically.

AddValue

Adds an adjustable value to the context.

csharp
IContextBuilder AddValue<T>(
    string name,
    AdjustableValue<T> value,
    AdjustAttribute attribute = null
)

Parameters:

  • name: Display name for the value
  • value: AdjustableValue wrapper containing getter/setter
  • attribute (optional): Configuration attribute (e.g., AdjustIntAttribute)

Example:

csharp
using Debology.Debby;
using Debology.Debby.Modules.Adjust;

public class DynamicValues : MonoBehaviour
{
    private int _coins = 0;
    private float _volume = 1f;

    void Start()
    {
        var coinsValue = new AdjustableValue<int>(
            () => _coins,
            value => _coins = value
        );

        var volumeValue = new AdjustableValue<float>(
            () => _volume,
            value => _volume = Mathf.Clamp01(value)
        );

        Debby.Adjust.NewContext("Player Data", gameObject)
            .AddValue("Coins", coinsValue, new (min: 0, max: 9999))
            .AddValue("Volume", volumeValue, new (
                min: 0f,
                max: 1f,
                isSlider: true,
                pageSize: 0.05f
            ))
            .Build();
    }
}

AddValueUnsafe

Adds an adjustable value using unsafe pointer access. Use with caution - the object containing the field must be pinned in memory.

csharp
IContextBuilder AddValueUnsafe<T>(
    string name,
    T* pointer,
    AdjustAttribute attribute = null
) where T : unmanaged

See Unsafe Usage for detailed information and examples.

AddAction

Adds an executable action as a button.

csharp
IContextBuilder AddAction(
    string name,
    Action action,
    AdjustActionAttribute config = null
)

Parameters:

  • name: Button label
  • action: Method to execute when clicked
  • config (optional): Configuration (icon, category, group, command, etc.)

Example:

csharp
using Debology.Debby;
using Debology.Debby.Modules.Adjust.Attributes;
using Debology.Debby.Elements;
using UnityEngine;

public class GameActions : MonoBehaviour
{
    void Start()
    {
        Debby.Adjust.NewContext("Game Controls", gameObject)
            .AddAction("Pause Game", TogglePause, new AdjustActionAttribute { Icon = DebbyIcon.Pause })
            .AddAction("Reset Level", ResetLevel, new AdjustActionAttribute { Icon = DebbyIcon.Refresh, Command = "reset" })
            .AddAction("Quit Game", QuitGame, new AdjustActionAttribute { Icon = DebbyIcon.Close, Category = "System" })
            .Build();
    }

    private void TogglePause()
    {
        Time.timeScale = Time.timeScale > 0 ? 0 : 1;
    }

    private void ResetLevel()
    {
        UnityEngine.SceneManagement.SceneManager.LoadScene(
            UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex
        );
    }

    private void QuitGame()
    {
#if UNITY_EDITOR
        UnityEditor.EditorApplication.isPlaying = false;
#else
        Application.Quit();
#endif
    }
}

AddAsyncAction

Adds an asynchronous action with optional progress reporting. Supports Task, Unity Awaitable (Unity 6.0+), and UniTask.

csharp
// Basic Task
IContextBuilder AddAsyncAction(
    string name,
    Func<Task> asyncAction,
    AdjustActionAttribute config = null
)

// Task with progress reporting
IContextBuilder AddAsyncAction(
    string name,
    Func<Action<float>, Task> asyncAction,
    AdjustActionAttribute config = null
)

Parameters:

  • name: Button label
  • asyncAction: Async method to execute (optionally with progress callback)
  • config (optional): Configuration (icon, category, group, command, etc.)

Example:

csharp
using System;
using System.Threading.Tasks;
using Debology.Debby;
using Debology.Debby.Modules.Adjust.Attributes;
using Debology.Debby.Elements;
using UnityEngine;

public class AsyncActions : MonoBehaviour
{
    void Start()
    {
        Debby.Adjust.NewContext("Async Operations", gameObject)
            .AddAsyncAction("Load Data", LoadDataAsync, new AdjustActionAttribute { Icon = DebbyIcon.Download })
            .AddAsyncAction("Process Assets", ProcessAssetsAsync, new AdjustActionAttribute { Icon = DebbyIcon.Settings, Command = "process" })
            .Build();
    }

    private async Task LoadDataAsync(Action<float> progress)
    {
        for (int i = 0; i <= 100; i += 10)
        {
            progress?.Invoke(i / 100f);
            await Task.Delay(200);
            Debug.Log($"Loading: {i}%");
        }
        Debug.Log("Data loaded!");
    }

    private async Task ProcessAssetsAsync()
    {
        Debug.Log("Processing...");
        await Task.Delay(1000);
        Debug.Log("Processing complete!");
    }
}

INFO

The AddAsyncAction method also has overloads for Unity's Awaitable (Unity 6.0+) and UniTask when the respective packages are available.

Build

Finalizes and registers the context. Must be called after adding all values and actions.

csharp
void Build()

Example:

csharp
Debby.Adjust.NewContext("My Context", gameObject)
    .AddValue("Value", myValue, new AdjustIntAttribute(min: 0, max: 100))
    .AddAction("Action", MyMethod)
    .Build(); // Don't forget to call Build()

AdjustableValue<T>

Wrapper class for runtime adjustable values that provides getter/setter access.

Constructors

csharp
// Constructor with getter/setter delegates
AdjustableValue(Func<T> getter, Action<T> setter)

// Constructor with initial value (internal storage)
AdjustableValue(T initialValue)

// Default constructor (internal storage with default value)
AdjustableValue()

Examples:

csharp
using Debology.Debby.Modules.Adjust;

// Wrap existing field
private int _score = 0;
var scoreValue = new AdjustableValue<int>(
    () => _score,
    value => _score = value
);

// Internal storage
var healthValue = new AdjustableValue<int>(100);

// Access the value
int currentHealth = healthValue.Value;
healthValue.Value = 50;

Type Adapters

Extend Adjust with custom UI controls for your own types.

RegisterTypeAdapter

Registers a custom adapter for a specific value type.

csharp
void RegisterTypeAdapter<TAdapter, TValue, TAttribute>()
    where TAdapter : AdjustTypeAdapter<TValue, TAttribute>, new()
    where TAttribute : AdjustAttribute

void RegisterTypeAdapter<TAdapter, TValue>()
    where TAdapter : AdjustTypeAdapter<TValue>, new()

Parameters:

  • TAdapter: Your adapter class
  • TValue: The value type to handle
  • TAttribute (optional): Associated attribute type

TIP

Check the Custom Types documentation for more info.