Game.Debug.DebugWatchValueAttribute
Assembly: Assembly-CSharp
Namespace: Game.Debug
Type: Class
Base: System.Attribute
Summary:
Attribute used to mark methods, properties or fields so their values can be watched by the game's debug/watch UI or tooling. It exposes display-related options such as a color for rendering the value, an update interval, and the length of the history buffer to keep for the watched values. The attribute is intended for lightweight instrumentation in mod/debug builds to visualize runtime values.
Fields
- None
This class does not declare any explicit private fields. Compiler-generated backing fields may exist for the auto-implemented properties.
Properties
-
public string color { get; set; }
Sets a color used when displaying the watched value. The attribute accepts a color string; common usages are named colors or hex color codes (e.g., "red" or "#FF00AA"). The exact accepted formats depend on the debug UI implementation. -
public int updateInterval { get; set; }
Controls how often the watched value should be updated in the debug UI. The default value is -1 (set in the source), which typically indicates "use the debug system's default update interval". The meaning (milliseconds, frames, or ticks) depends on the consuming debug/watch system. -
public int historyLength { get; set; }
Size of the history buffer to keep for the watched value (used for sparklines/graphs or recent-value history). Default is 128.
Constructors
public DebugWatchValueAttribute()
The attribute has no explicit constructors in source; the default parameterless constructor is available. All configuration is done through the public properties.
Methods
- None
There are no methods declared on this attribute type.
Usage Example
using Game.Debug;
public class ExampleComponent
{
// Watch a property with custom color and history length.
[DebugWatchValue(color = "cyan", updateInterval = 250, historyLength = 256)]
public float CpuLoad { get; set; }
// Watch a private field; color can be expressed as hex.
[DebugWatchValue(color = "#FF8800", historyLength = 64)]
private int _frameCounter;
// Use default settings (no arguments).
[DebugWatchValue]
public int ActiveObjects => GetActiveObjectsCount();
private int GetActiveObjectsCount()
{
// implementation...
return 0;
}
}
Notes and tips: - AttributeUsage is limited to Method, Property and Field (as declared). It is not marked AllowMultiple, so you cannot apply multiple DebugWatchValueAttribute instances to the same target. - updateInterval default -1 commonly means "use the debug system default"; consult the specific debug tool/docs for exact semantics (milliseconds vs frames). - The debug UI/system that consumes this attribute is responsible for interpreting the color string and rendering history graphs using historyLength.