> For the complete documentation index, see [llms.txt](https://postica.gitbook.io/binding-system-3/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://postica.gitbook.io/binding-system-3/reference/bind-flags.md).

# BindFlags

The flags behind everything the bind menu toggles.

`BindFlags` is a 32-bit bitmask on every binding. Almost everything the bind menu switches is one of these, so this page doubles as the reference for the serialized data you may see in a diff.

There is a second, smaller enum, `BindFlags2`, for the lifecycle update points that did not fit.

## Behaviour

<table><thead><tr><th width="290">Flag</th><th>What it does</th></tr></thead><tbody><tr><td><code>None</code></td><td>Nothing set.</td></tr><tr><td><code>LiveDebug</code></td><td>Show every pipeline stage's value each frame. See <a href="/binding-system-3/project-tools/diagnostics/live-debug.md">Live Debug</a>.</td></tr><tr><td><code>ShowPathValuePreview</code></td><td>Show the value at the end of the path. See <a href="/binding-system-3/project-tools/diagnostics/path-value-preview.md">Path Value Preview</a>.</td></tr><tr><td><code>AutoUpdate</code></td><td>Refresh once per frame, between <code>Update</code> and <code>LateUpdate</code>. The only automatic update a <code>Bind&#x3C;T></code> field has. Enabled implicitly when something subscribes to a change event.</td></tr><tr><td><code>EnableEvents</code></td><td>Enable the serialized <code>UnityEvent</code> on this binding.</td></tr><tr><td><code>SourceNotNeeded</code></td><td>This binding works without a source. What the <strong>Nothing</strong> menu entry sets.</td></tr><tr><td><code>PropagateUndefinedValue</code></td><td>A null anywhere in the path yields null, or the default for a value type, instead of logging an error and leaving the value unchanged. The <strong>Propagate Nulls</strong> option.</td></tr><tr><td><code>OptimizeUpdate</code></td><td>Only do work when the source is active and the data changed. See <a href="/binding-system-3/overview/modes-and-updates.md#optimized-update">Optimized Update</a>.</td></tr><tr><td><code>UseTimeUpdateInterval</code></td><td>The interval is in seconds rather than frames.</td></tr><tr><td><code>UIInitialized</code></td><td>Editor bookkeeping.</td></tr></tbody></table>

## Update points

These are read by `BindProxy`, so they take effect on a [proxy binding](/binding-system-3/overview/proxy-bindings.md) and are ignored on a `Bind<T>` field. The equivalent for a bind field is `AutoUpdate` above. See [Two Ways to Bind](/binding-system-3/overview/two-ways-to-bind.md).

<table><thead><tr><th width="290">Flag</th><th>What it does</th></tr></thead><tbody><tr><td><code>UpdateInEditor</code></td><td>Update at edit time, without play mode.</td></tr><tr><td><code>UpdateOnChange</code></td><td>Update when the source value changes.</td></tr><tr><td><code>UpdateOnUpdate</code></td><td>Read before <code>Update</code>, write after.</td></tr><tr><td><code>UpdateOnFixedUpdate</code></td><td>Read before <code>FixedUpdate</code>, write after.</td></tr><tr><td><code>UpdateOnLateUpdate</code></td><td>Read before <code>LateUpdate</code>, write after.</td></tr><tr><td><code>UpdateOnPrePostRender</code></td><td>Read before the frame renders, write immediately after, which lands in the next frame.</td></tr><tr><td><code>UpdateOnEnable</code></td><td>Update when the context GameObject is activated.</td></tr></tbody></table>

### BindFlags2

<table><thead><tr><th width="290">Flag</th><th>What it does</th></tr></thead><tbody><tr><td><code>UpdateOnAwake</code></td><td>The value is ready inside your <code>Awake</code>.</td></tr><tr><td><code>UpdateOnStart</code></td><td>Ready inside your <code>Start</code>. Not available when the context is an asset.</td></tr><tr><td><code>UpdateOnDisable</code></td><td>Ready inside <code>OnDisable</code>.</td></tr><tr><td><code>UpdateOnDestroy</code></td><td>Ready inside <code>OnDestroy</code>.</td></tr></tbody></table>

See [Bind Modes and Update Points](/binding-system-3/overview/modes-and-updates.md).

## Source modes

Each mode is a combination of three bits, so they are **mutually exclusive**, not additive. Use the named values.

<table><thead><tr><th width="290">Flag</th><th>What it does</th></tr></thead><tbody><tr><td><code>SourceByValue</code></td><td>0. A direct object reference. The default.</td></tr><tr><td><code>SourceByVariable</code></td><td>A named <a href="/binding-system-3/overview/bind-variables.md">bind variable</a>.</td></tr><tr><td><code>SourceByNameOrPath</code></td><td>A GameObject name, or a slash path.</td></tr><tr><td><code>SourceByTag</code></td><td>The first object with a tag.</td></tr><tr><td><code>SourceByPattern</code></td><td>A wildcard path. Expensive.</td></tr><tr><td><code>SourceInContext</code></td><td>Search from the owning object outwards.</td></tr><tr><td><code>SourceInScene</code></td><td>Search all loaded scenes for a type.</td></tr><tr><td><code>SourceByStatic</code></td><td>No instance. The path resolves against a type.</td></tr></tbody></table>

See [Sources](/binding-system-3/overview/sources.md).

## Search modes

Combine with `SourceByNameOrPath`, `SourceByTag` or `SourceInContext`.

<table><thead><tr><th width="290">Flag</th><th>What it does</th></tr></thead><tbody><tr><td>(none)</td><td>Only the object found.</td></tr><tr><td><code>SearchInChildren</code></td><td>The object and its children.</td></tr><tr><td><code>SearchInParents</code></td><td>The object and its parents.</td></tr><tr><td><code>SearchInHierarchy</code></td><td>Children first, then parents, so the closest match wins.</td></tr></tbody></table>

## Working with them in code

`Flags` is read-only on bind data. Change it through `TryEnableFlag`:

```csharp
var data = new BindData(source, "position.x", null, -1);

data.TryEnableFlag(BindFlags.UpdateOnLateUpdate, true);
data.TryEnableFlag(BindFlags.OptimizeUpdate, true);
data.TryEnableFlag(BindFlags.LiveDebug, false);

if (data.HasFlags(BindFlags.OptimizeUpdate)) { /* ... */ }
```

Extension methods on the enum itself:

```csharp
flags.HasFlagFast(BindFlags.UpdateOnUpdate);        // aggressively inlined test
flags.HasAnyOfFlags(BindFlags.SearchAllFlags);
flags = flags.WithFlag(BindFlags.AutoUpdate);
flags = flags.WithoutFlag(BindFlags.LiveDebug);
flags = flags.ClearReservedFlags();                 // before persisting
```

{% hint style="warning" %}
Several bits are reserved (`__Reserved`, `__ReservedFlag1` to `3`, and bits 29 to 31 for future extensions). Do not set them, and clear them with `ClearReservedFlags()` before persisting a value you assembled yourself.
{% endhint %}

## Composed values

Convenience combinations, mostly for masking rather than for setting:

<table><thead><tr><th width="290">Value</th><th>What it is</th></tr></thead><tbody><tr><td><code>SourceModeAllFlags</code></td><td>The three source-mode bits.</td></tr><tr><td><code>SearchAllFlags</code></td><td>All search combinations.</td></tr><tr><td><code>SourceAllFlagsAndSearchAllFlags</code></td><td>Both groups.</td></tr><tr><td><code>FlagsToClear</code></td><td>The reserved bits, cleared before persistence.</td></tr></tbody></table>
