Description
The As
property of the SerializedProperty
class provides an accessor to the property's value, allowing it to be accessed or modified in a type-safe manner. This property is virtual, meaning it can be overridden in derived classes to provide custom behavior.
Usage
Use the As
property to access or modify the value of a serialized property in a type-safe way. This is particularly useful when dealing with properties whose types are not known at compile time.
Example
// Example of using the As property
SerializedProperty property = ...; // Assume this is initialized
var accessor = property.As;
// Use the accessor to get or set the value
var value = accessor.GetValue<int>();
accessor.SetValue(42);