Skip to content

WatchReference

WatchReference<T> is a struct type returned by most Watch methods, providing straightforward access to common operations for watch variables.

ChildCount

public int ChildCount
Returns the number of child variables. Returns 0 if there are none.

GetChildNames

public IEnumerable<string> GetChildNames()
Retrieves a collection containing the names of all child variables.

GetOrAdd

public WatchReference<V> GetOrAdd<V>(string path)
Retrieves an existing child variable or adds a new one with the specified name path and type V. This method is similar to GetOrAdd().

SetAlwaysCollapsable

public WatchReference<T> SetAlwaysCollapsable()
Configures the variable columns to always be collapsable. If Collapse button is enabled in the Watch window, values from these variables will behave as if they haven't changed. This is useful for constantly changing values, to prevent cluttering.

SetSortOrder

public WatchReference<T> SetSortOrder(int value)
Assigns a sorting order to the variable, determined by the specified value. This functions similarly to scripting execution order in Unity: a higher value places the variable lower in the display order and vice versa. If no sorting order is specified, it defaults to the creation order of the variables, with a float value expected between 0 and 1.

SetTitleFormat

public WatchReference<T> SetTitleFormat(WatchTitleFormat format)
Overrides format for the variable's display area.

SetDefaultValueFormat

public WatchReference<T> SetDefaultValueFormat(WatchValueFormat format)
Overrides the default format for the variable's values.

AddConditionalValueFormat

public WatchReference<T> AddConditionalValueFormat(Func<T, bool> condition, WatchValueFormat format)
Defines a rule for formatting values with format based on a condition. condition is a delegate that takes a value of type T and returns whether the condition is met.

If multiple conditions are true for the same value

If multiple positive conditions are present, only the last one will take effect.

public WatchReference<T> AddConditionalValueFormat(Func<T, bool> condition, Func<T, WatchValueFormat> dynamicFormat)
Defines a rule for formatting values, similar to the previous method, but allows for dynamicFormat that determines the format based on the value.

PushValueFormat

public WatchReference<T> PushValueFormat(WatchValueFormat format)
Directly pushes value format to the variable. Pushing formats functions like pushing values and must be done before calling Watch.UpdateAll().

PushExtraText

public WatchReference<T> PushExtraText(string extraText)
Pushes additional text 'extraText' to the variable. Similar to pushing values, this must also be done before Watch.UpdateAll() is called.

PushEmptyValue

public WatchReference<T> PushEmptyValue(bool withRoot = true, int maxRecursionDepth = 10)
Pushes an empty value to the variable and all of its children recursively, constrained by maxRecursionDepth. If withRoot is set to false, the empty value will not be pushed to the target variable itself, only to its children.