Sandbox.SerializedObject/PropertyChangedDelegate OnPropertyChanged { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The OnPropertyChanged property of the SerializedObject class is a delegate that is invoked whenever a property within the serialized object changes. This allows for custom logic to be executed in response to property changes, such as updating UI elements or triggering other events.

Usage

To use the OnPropertyChanged property, you need to assign a method that matches the PropertyChangedDelegate signature. This method will be called whenever a property change is detected in the serialized object.

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.");
}

// Create an instance of SerializedObject
SerializedObject mySerializedObject = new SerializedObject();

// Assign the handler to the OnPropertyChanged delegate
mySerializedObject.OnPropertyChanged += OnPropertyChangeHandler;

// Now, whenever a property changes in mySerializedObject, OnPropertyChangeHandler will be invoked.