FactorableData
Abstract record base class for all data attached to factory-spawned objects. Uses C# record semantics to enable value-based equality and built-in with expression support for shallow copying. Designed to be subclassed with game-specific fields.
Definition
Namespace: Paragon.Core.ScriptableFactory Assembly: Paragon.dll
[Serializable]
public abstract record FactorableDataRemarks
FactorableData is a C# record (reference type with value semantics), which provides:
Value equality — two data instances with the same field values are considered equal.
withexpression support — enables shallow copying viadata with { }, used byFactorableDataUtility.CreateCopy()inSHALLOWmode.Immutability-friendly — records encourage immutable patterns, though fields can still be mutable for Unity serialization.
Data records are stored on ScriptableFactory<TObject, TData> assets and deep-copied before being applied to spawned objects (via FactorableDataUtility), ensuring each object instance gets its own data copy.
Fields marked with [Overridable] can be overridden per-variant or per-spawn through the DataOverride / DataVariantSystem without modifying the source data.
Quick Lookup
Define custom data
Subclass FactorableData with fields
Deep copy
FactorableDataUtility.CreateCopy(data)
Shallow copy
FactorableDataUtility.CreateCopy(data, CopyMode.SHALLOW)
Mark field as overridable
Apply [Overridable] attribute
Extension Points
Required Overrides
None. FactorableData has no abstract members — it serves as a marker base type.
Pattern: Defining Custom Data
Subclass and add serialized fields:
Implementation Requirements
When subclassing FactorableData, you MUST:
Mark the class with
[Serializable]for Unity/Odin serializationUse the
recordkeyword (notclass) to maintain copy semantics
You SHOULD:
Mark fields with
[Overridable]if they should be customizable viaDataOverride/ variantsUse
publicfields or[OdinSerialize]for Inspector visibilityKeep fields simple and serializable (avoid non-serializable reference types)
Examples
Basic Data Record
Using Data with a Factorable Object
See Also
FactorableDataUtility — utility for copying data records
ScriptableFactoryDatabase — factory lookup by hash
Last updated