Reference for every public type and member in the No-Code area. Red text flags the exceptions a member can throw. See the API overview for the other areas.

No-CodePersist data straight from the inspector, no scripting.

PersistentVariables

SO

A persistent object holding a named, typed set of variables authored in the inspector. It derives from PersistentScriptableObject, so the full load / save API is available on the asset.

Read & write values
T Get<T>(string name, T fallback = default)Read a variable, or the fallback when missing or an incompatible type.
bool TryGet<T>(string name, out T value)Read, returning false when missing or incompatible.
void Set<T>(string name, T value)Write, creating it when absent. Writing an equal value-type/string is a no-op that does not re-raise Changed. Throws ArgumentException (null/empty name, or null untyped value), NotSupportedException (no registered variable type for T), InvalidOperationException (exists with an incompatible type/shape).
bool TrySet<T>(string name, T value)Write, returning false instead of throwing.
void NotifyChanged(string name)Flag a reference-type value changed after mutating it in place.
Lists
ObservableList<T> GetList<T>(string name)The live list behind a list variable (created empty when absent). Throws ArgumentException (null/empty name), NotSupportedException (no registered type), InvalidOperationException (name exists with a different shape/type).
bool TryGetList<T>(string name, out ObservableList<T> list)The list, returning false instead of throwing.
Maps
ObservableDictionary<TKey, TValue> GetMap<TKey, TValue>(string name)The live map behind a map variable (created empty when absent). Throws ArgumentException (null/empty name), NotSupportedException (no registered type), InvalidOperationException (name exists with a different shape/type).
bool TryGetMap<TKey, TValue>(string name, out ObservableDictionary<TKey, TValue> map)The map, returning false instead of throwing.
Schema & identity
int Count { get; } / IReadOnlyList<string> Keys { get; } / string GlobalIdentifier { get; }How many variables; every variable name; the asset's stable global id.
bool Has(string name) / Type TypeOf(string name) / bool IsList(string) / IsMap(string)Presence, value type, and shape of a variable.
bool MapTypesOf(string name, out Type keyType, out Type valueType)Key/value types of a map variable.
string NameOf(string id) / IdOf(string name)Map between a variable's display name and its stable id (IdOf returns null for a variable created at runtime through Set, which has no stable id).
bool Remove(string name) / void Clear()Remove one variable, or all of them.
bool ResetVariable(string name) / void ResetVariable(params string[] names)Reset variable(s) to their authored default.
Events
event Action<string> ChangedA variable changed (its name is passed).
event Action ReloadedThe backing store was rebuilt (after a load/reset): re-fetch any cached list or map.

Variable references

struct

Serializable fields that point at one variable inside a PersistentVariables asset, filled by dragging a variable from its inspector (or picking it from a dropdown). Each stores the asset plus the variable's stable id, so renaming the variable never breaks the link. Choose the one matching how strict the field should be:

  • VariableRef: untyped, any shape; you pass the type at each call (Get<T> / GetList<T> / GetMap<TKey,TValue>).
  • VariableValueRef<T>: one value of T; Get/Set need no type argument and the inspector only offers matching variables.
  • VariableListRef<T>: a list of T, read and edited live through List.
  • VariableMapRef<TKey, TValue>: a map, read and edited live through Map.
Common to all four
PersistentVariables Variables { get; }The asset this points into.
string Id { get; } / string Name { get; }The variable's stable id, and its current display name (resolved from the id, falling back to the last known name).
bool IsSet { get; } / bool Exists { get; }Whether an asset + variable are assigned; whether that variable currently exists (the typed refs also require the matching type / shape).
bool Reset()Reset the variable to its authored default; false when no asset is assigned.
VariableRef: untyped
Type Type { get; }The variable's stored type, or null when missing or unsupported.
T Get<T>(T fallback = default) / bool TryGet<T>(out T)Read as T (fallback / false when missing or a different type).
void Set<T>(T) / bool TrySet<T>(T)Write, creating it when absent (TrySet returns false instead of throwing). A silent no-op when no asset is assigned; otherwise Set throws like PersistentVariables.Set.
ObservableList<T> GetList<T>()The live list (created empty when absent), or null when the variable is not a list of T.
ObservableDictionary<TKey, TValue> GetMap<TKey, TValue>()The live map (created empty when absent), or null when the variable is not a map of those types.
VariableValueRef<T>: single value
T Value { get; set; }Shorthand for Get() / Set(value) with the default fallback.
T Get(T fallback = default) / bool TryGet(out T)Read (fallback / false when missing or stored as a different type).
void Set(T) / bool TrySet(T)Write, creating it when absent (TrySet returns false instead of throwing). A silent no-op when no asset is assigned; otherwise Set throws like PersistentVariables.Set.
Type Type { get; }The variable's actual stored type (may differ from T if the asset was edited since), or null when missing / unsupported.
VariableListRef<T>: list
ObservableList<T> List { get; } / bool TryGetList(out ObservableList<T>)The live list, created empty when absent, or null / false when not a list of T.
VariableMapRef<TKey, TValue>: map
ObservableDictionary<TKey, TValue> Map { get; } / bool TryGetMap(out ObservableDictionary<TKey, TValue>)The live dictionary, created empty when absent, or null / false when not a map of those types.

Variable components

MB

MonoBehaviours wiring variables to a scene, no code. Each exposes VariableRef Variable { get; } (from the abstract VariableComponent base).

VariableComponent (abstract) · VariableRef Variable { get; } · protected virtual void OnEnable() / OnDisable()Base for the components below. When overriding OnEnable / OnDisable, call base so the component stays registered.
VariableBinderTwo-way bind a variable to a target member (with an optional value converter); a BindingDirection picks the flow.
VariableListenerRaise a typed UnityEvent on change (nested StringEvent / FloatEvent / IntEvent / BoolEvent).
VariableSetter · void Apply() / SetBool/SetInt/SetFloat/SetString(value) / Toggle() / Increment()Change a variable from a UnityEvent. Operation: Set, Toggle, Increment, Add, Reset.
Enums
VariableSetter.OperationSet, Toggle, Increment, Add, Reset.
BindingDirectionAuto, TwoWay, VariableToTarget, TargetToVariable.

Observables

class

The live collection backings behind list and map variables. Editing one notifies its owning PersistentVariables (raising Changed) and marks the asset dirty, so the change persists. Do not cache an instance across a load or reset: a reload rebuilds the backing store, so a kept reference goes stale and stops persisting, re-fetch it (e.g. on Reloaded).

ObservableList<T>
Standard IList<T> membersIndexer, Add, Insert, Remove, RemoveAt, Clear, Count, IndexOf, Contains, enumeration, etc.
ObservableDictionary<TKey, TValue>
Standard IDictionary<TKey, TValue> membersIndexer, Keys, Values, Remove, Clear, Count, ContainsKey, TryGetValue, enumeration, etc.
void Add(TKey key, TValue value)Add a pair. Throws ArgumentException when the key is already present.

Codecs & converters

classextending

Add a persistable No-Code type with a codec; bridge differing types in a binder with converters.

Codecs
VariableTypeCodec (abstract) · abstract string Format(object) / abstract object Parse(string)String round trip for a type.
VariableTypeCodec<T> (abstract) · protected abstract string Write(T) / protected abstract T Read(string)The typed codec to implement (an empty string passed to Read means the default); pair with [VariableType(type, id)].
VariableTypes (static) · void Register(Type, string id, VariableTypeCodec)The registry of supported variable types. [VariableType] codecs are discovered automatically; Register adds (or replaces) one manually. Throws ArgumentNullException / ArgumentException on a null or empty argument, NotSupportedException for a collection type (register the element type instead).
bool TryGetCodec(Type, out VariableTypeCodec) / TryGetCodec(string id, out VariableTypeCodec) / TryGetId(Type, out string) / TryGetType(string id, out Type)Look up between the registered types, their stable save ids and their codecs.
IEnumerable<KeyValuePair<string, Type>> All { get; } / string EnumId(Type enumType)Every registered id and type (unregistered enums excluded); the on-demand id an unregistered enum's values are stored under (that id embeds the enum's full type name, so register an explicit codec for an enum you may later rename).
Converters
ValueConverter (abstract) · Type From / To { get; }, object Convert(object) · ValueConverter<TFrom, TTo> (abstract) · protected abstract TTo Convert(TFrom value)Turn one type into another for a binder (prefer ValueConverter<TFrom, TTo>; register two, one each way, for a two-way binding).
ValueConverters (static) · void Register(ValueConverter) / bool CanConvert(Type, Type) / TryConvert(object, Type, out object) / TryConvert(object, Type, CultureInfo, out object)The converter registry plus built-in number/enum/to-string rules. Register throws ArgumentNullException on a null converter.

Input & Localization

static

Extension-method helpers that make InputBinding and a locale persistable through a PersistentVariables variable. (The codecs and widgets they rely on register themselves; only these statics are public.)

InputBindingPersistence
bool ApplyTo(this InputBinding stored, InputAction action, int bindingIndex = 0)Apply a stored binding override onto an action.
bool ApplyBinding(this PersistentVariables, string name, InputAction, int = 0) / CaptureBinding(this PersistentVariables, string, InputAction, int = 0)Apply / capture an action's binding to a variable.
InputActionRebindingExtensions.RebindingOperation RebindAndStore(this PersistentVariables, string name, InputAction, int bindingIndex = 0, Action onComplete = null, Action onCancel = null)Start an interactive rebind, then capture the new binding into the variable when it completes. The caller owns the returned operation's lifetime: keep it and call its Cancel in OnDisable / OnDestroy, or the completion callback can run after the object is gone.
LocalePersistence
bool ApplyLocale(this PersistentVariables, string name) / CaptureLocale(this PersistentVariables, string name)Apply the stored locale as the active one / capture the active locale into a variable. Call the LocalePersistence helpers once localization is initialized (e.g. after awaiting LocalizationSettings.InitializationOperation), else they return false.
bool SelectLocale(this PersistentVariables, string name, LocaleIdentifier locale)Set and store a chosen locale (same initialization requirement as above, else returns false).

Attributes

attr
[VariableType(Type type, string id)]
Type Type { get; }, string Id { get; }
Register a No-Code variable codec for a type, saved under a stable id (see Codecs & converters).