-
Notifications
You must be signed in to change notification settings - Fork 9
[MedicineSettings]
[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.
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.
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>();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
IInstanceIndexhas few drawbacks,truemay become the default behavior in the future.
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].
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:
-
Automaticis recommended: optimized release builds, safety checks in editor/debug builds. -
ForceEnabledis useful when debugging a release build. -
ForceDisabledis useful for previewing fully stripped runtime code.