Skip to content
apk edited this page Feb 2, 2026 · 1 revision

[MedicineSettings] is an assembly-level attribute that sets default behavior for other Medicine features. Use it to configure your whole assembly once, then override per type or method when needed.

Quick start

Put the attribute at the top of any .cs file in your assembly:

[assembly: MedicineSettings(
    makePublic: true,
    alwaysTrackInstanceIndices: false,
    singletonStrategy: SingletonAttribute.Strategy.Recommended,
    debug: MedicineSettingsAttribute.DebugMode.Automatic
)]

This is the default configuration unless you override it.

Attribute parameters

makePublic

Controls the default access level for properties generated by [Inject].

  • true (default): generated properties are public.
  • false: generated properties are protected (or private on sealed types).

You can still override this per method:

[Inject(makePublic: false)]
void Awake() => Rigidbody = GetComponent<Rigidbody>();

alwaysTrackInstanceIndices

If true, the generator automatically implements IInstanceIndex on all [Track] types without adding interfaces manually.

Default is false.

Notes:

  • This affects all tracked types in the assembly.
  • Per-type tracking options like transform access arrays are still controlled by [Track].
  • Since using IInstanceIndex has few drawbacks, true may become the default behavior in the future.

singletonStrategy

Sets the default SingletonAttribute.Strategy for [Singleton] types.

Default is Replace.

Per-type [Singleton(strategy: ...)] values override the assembly default from [MedicineSettings].

For the description of possible flag values (Replace, KeepExisting, LogWarning, AutoInstantiate, etc.), see [Singleton].

debug

Controls whether the generator emits debug-only validation (null checks, error logs, etc.).

public enum DebugMode
{
    Automatic,     // default: editor + debug builds only
    ForceEnabled,  // always include debug checks
    ForceDisabled, // never include debug checks
}

Notes:

  • Automatic is recommended: optimized release builds, safety checks in editor/debug builds.
  • ForceEnabled is useful when debugging a release build.
  • ForceDisabled is useful for previewing fully stripped runtime code.

Clone this wiki locally