OverridableAttribute
Field-level attribute that marks a FactorableData field as eligible for override by the variant system. Extends OdinSerializeAttribute to ensure the marked field is also Odin-serialized.
Definition
Namespace: Paragon.Core.ScriptableFactory
Assembly: Paragon.dll
[AttributeUsage(AttributeTargets.Field)]
public class OverridableAttribute : OdinSerializeAttributeInherits: Sirenix.Serialization.OdinSerializeAttribute
Remarks
This attribute serves a dual purpose:
Variant eligibility —
DataOverride.CanOverrideField()checks for this attribute via reflection. Fields without[Overridable]are rejected when adding field overrides.Odin serialization — Inheriting from
OdinSerializeAttributeensures marked fields are serialized by Odin, even if they would not be serialized by Unity's default serializer.
An optional OverriderType parameter allows specifying a custom DataFieldOverride subclass for fields that need specialized override logic (e.g., list merging, conditional application).
Quick Lookup
Mark a field as overridable
[Overridable] public float health;
Use a custom overrider
[Overridable(typeof(MyCustomOverride))] public List<Item> items;
Check if a field is overridable
DataOverride.CanOverrideField(fieldName)
Properties
OverriderType
Optional custom DataFieldOverride subclass type used instead of the default DataFieldOverride<TField>.
When null (default), the system auto-creates DataFieldOverride<TField> using the field's type. When set, the system creates an instance of the specified type instead.
Constructor
overriderType
Type
Custom DataFieldOverride subclass type, or null for default behavior
Usage Examples
Basic usage
Custom overrider type
Common Pitfalls
Only works on fields, not properties
[AttributeUsage(AttributeTargets.Field)] restricts this attribute to fields only. Applying it to a property will compile but will not be discovered by DataOverride.GetOverridableFields(), which uses GetFields().
Custom overrider must extend DataFieldOverride
The OverriderType must be a class with a constructor matching (string fieldName, object fieldValue). The system creates instances via Activator.CreateInstance(overriderType, fieldName, fieldValue).
See Also
DataOverride — uses this attribute to discover overridable fields
DataFieldOverride — base class for override instances
FactorableData — base record class whose fields are marked
Last updated