Skip to content

Crumpet-Labs/Buttr.Unity

Buttr

A lightweight dependency-injection container for Unity 6+.

Release License Unity 6+

Buttr vendors the engine-agnostic Buttr.Core DI library and adds Unity-specific integration on top: source-generated MonoBehaviour injection, ScriptableObject registration, scene-walking injectors, and editor scaffolding for a suffix-driven architecture.

Installation

Window > Package Manager+Install package from git URL:

https://github.com/Crumpet-Labs/Buttr.Unity.git?path=Assets/Plugins/Buttr

Pin a version by appending #v2.3.0. Requires Unity 6.0+.

Getting started

  1. Tools > Buttr > Setup Project scaffolds _Project/, Main.unity boot scene, Program.cs, ProgramLoader.

  2. Register a service in Program.cs:

    var builder = new ApplicationBuilder();
    builder.Resolvers.AddSingleton<IGreeter, Greeter>();
    return builder.Build();
  3. Inject it into a partial MonoBehaviour:

    public partial class Welcome : MonoBehaviour {
        [Inject] private IGreeter m_Greeter;
    }
  4. Add a SceneInjector to your scene, press Play.

Full walkthrough: Docs/Guides/GettingStarted.md.

Documentation

Topic Guide
UPM install, updating, version pinning Installation
First project end-to-end Getting Started
Suffix-driven architecture Conventions
[Inject] + injectors MonoBehaviour Injection
Designer-facing data ScriptableObjects
Setup project + scaffolding Editor Tooling
Boot pipeline Loaders

Engine-agnostic core (aliasing, All<T>(), DIBuilder, Hidden, analyzer catalogue): Buttr.Core docs.

Contributing

Contributions are welcome. Open an issue first to discuss what you'd like to change. See CONTRIBUTING.md.

License

MIT — see LICENSE.

About

A lightweight Dependency Injection framework for Unity

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors