Sandbox.SerializedObject/PropertyPreChangeDelegate OnPropertyPreChange { get; set; }

robot_2Generated
code_blocksInput

Description

The OnPropertyPreChange property of the SerializedObject class is a delegate that is invoked before a property of the serialized object is changed. This allows for custom logic to be executed prior to the modification of a property, such as validation or logging.

Usage

To use the OnPropertyPreChange delegate, assign a method that matches the PropertyPreChangeDelegate signature. This method will be called before any property change occurs on the serialized object.

Example usage:

SerializedObject mySerializedObject = new SerializedObject();
mySerializedObject.OnPropertyPreChange += MyPreChangeHandler;

void MyPreChangeHandler(SerializedProperty property)
{
    // Custom logic before the property changes
    if (property.Name == "SomeProperty")
    {
        // Perform validation or logging
    }
}

Example

SerializedObject mySerializedObject = new SerializedObject();
mySerializedObject.OnPropertyPreChange += MyPreChangeHandler;

void MyPreChangeHandler(SerializedProperty property)
{
    // Custom logic before the property changes
    if (property.Name == "SomeProperty")
    {
        // Perform validation or logging
    }
}