ActionVariable
Abstract wrapper that pairs an internal Variable storage backend with optional reference semantics. When an ActionVariable references another, GetValue() transparently delegates to the referenced variable, enabling data flow between actions without direct coupling.
The generic subclass ActionVariable<TVariable> adds a typed Value property for convenient Inspector display via Odin.
Definition
Namespace: Paragon.Core.ActionSystem Assembly: Paragon.dll
[Serializable]
public abstract class ActionVariable[Serializable]
public class ActionVariable<TVariable> : ActionVariableQuick Lookup
Get the variable's value
actionVariable.GetValue()
Get typed value (generic)
actionVariable.Value (on ActionVariable<T>)
Set the variable's value
actionVariable.SetValue(obj)
Set typed value (generic)
actionVariable.Value = val (on ActionVariable<T>)
Link to another variable
actionVariable.SetReference(other) then IsReference = true
Check if backed by a field
actionVariable.IsFieldVariable
Get the variable name
actionVariable.Name
Get the variable type
actionVariable.Type
Properties
Name
The name of the underlying variable. For field variables this is the field name; for dynamic variables it is the name passed at creation.
Type
The System.Type of the variable's value.
IsReference
When true, GetValue() delegates to the referenced ActionVariable instead of reading the local variable.
IsFieldVariable
Returns true if the underlying storage is a FieldVariable (reflection-backed).
Value (generic subclass only)
Typed accessor available on ActionVariable<TVariable>. Internally calls GetValue() / SetValue().
Constructors
Both constructors are internal — instances are created by ActionVariables, not by user code.
ActionVariable(Action, FieldInfo)
Creates a field-backed variable. The underlying storage is a FieldVariable.
action
Action
The owning action instance
fieldInfo
FieldInfo
Reflection info for the field to bind
ActionVariable(Action, Type, string, object)
Creates a dynamic variable. The underlying storage is a DynamicVariable.
action
Action
The owning action instance
type
Type
The value type
name
string
The variable name
value
object
Optional initial value
Methods
GetValue
Returns the current value. If IsReference is true and a reference is set, returns the referenced variable's value instead.
Returns: The variable's value as object, or null if the reference is null in reference mode.
SetValue
Sets the value on the underlying Variable storage (field or dynamic). This always writes to the local variable, regardless of IsReference.
value
object
The value to assign
UpdateValue
Reads the current value (respecting reference mode) and writes it back to the local variable. Used by ActionVariables.ApplyFieldVariables() to sync referenced values into fields before execution.
SetReference
Sets or clears the reference to another ActionVariable. When setting a non-null reference, the local value is cleared to default.
reference
ActionVariable
The variable to reference, or null to clear
Assertion: The reference's Type must be assignable to this variable's Type (checked via Type.IsOfType()). Passing an incompatible type will trigger a Debug.Assert.
GetReference
Returns the currently referenced ActionVariable, or null if none is set.
Returns: The referenced ActionVariable or null.
Common Pitfalls
SetValue does not write through references SetValue() always writes to the local variable, even when IsReference is true. To propagate a value through a reference chain, call SetValue() on the target variable directly.
Type mismatch on reference SetReference() asserts type compatibility. Ensure reference.Type is assignable to this variable's Type before calling.
Null reference in reference mode When IsReference is true but no reference has been set (or it was set to null), GetValue() returns null. Guard against this when working with value types.
See Also
ActionVariables — the container that creates and manages
ActionVariableinstancesVariable — the internal storage base class
Action — the base class that owns variables
Action Variables Subsystem — subsystem overview
Last updated