Leveraging Watchers
Enhance your inspection by attaching watchers to your inspected members. Watchers notify you of real-time changes in values.
Adding Watchers
You can add a watcher right after your InspectMe()
call. Customize the watcher's behavior with various parameters, like notification methods and activation settings.
Info
For a comprehensive guide on adding and configuring watchers, visit our Add Watcher Methods page.
Correct Usage of AddWatcher
// Basic watcher addition with notification type
this.InspectMe(x => x.myValue).AddWatcher(WatcherNotifications.Log);
// Using a callback with a watcher
this.InspectMe(x => x.myValue).AddWatcher(OnValueChanged);
// Callback example
private void OnValueChanged(int newValue)
{
// Handle the value change here
}
Incorrect Use Cases for Watchers
Watchers are powerful but have limitations. Avoid using them in unsupported scenarios.
// 1- Adding a watcher with null callback or None notification
this.InspectMe(x => x.myValue).AddWatcher(null); // Null callback
this.InspectMe(x => x.myValue).AddWatcher(WatcherNotifications.None); // None notification
// 2- Adding a watcher to unsupported types
this.InspectMe(x => x.myClass).AddWatcher(OnClassChanged); // Not valid for classes/structs
Remember
Watchers are primarily for debugging purposes in the Unity Editor and should not be used for game logic in production.
For further assistance, don't hesitate to reach out to our support section.