Description
The OnPropertyChanged
property of the SerializedObject
class is a delegate that is invoked whenever a property within the serialized object changes. This allows developers to attach custom logic that should be executed in response to property changes, such as updating UI elements or triggering other events.
Usage
To use the OnPropertyChanged
property, assign a method that matches the PropertyChangedDelegate
signature to it. This method will be called whenever a property change occurs within the SerializedObject
.
Example
// Example of using OnPropertyChanged
// Define a method that matches the PropertyChangedDelegate signature
void OnPropertyChangeHandler(SerializedProperty property)
{
// Custom logic to handle the property change
Console.WriteLine($"Property {property.Name} has changed.");
}
// Assuming 'serializedObject' is an instance of SerializedObject
serializedObject.OnPropertyChanged += OnPropertyChangeHandler;
// Now, whenever a property changes in 'serializedObject',
// OnPropertyChangeHandler will be invoked.