Unity - Scripting API: SerializedProperty
class in UnityEditor
Success!
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Submission failed
For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
Description
SerializedProperty and SerializedObject are classes for editing properties on objects in a completely generic way that automatically handles undo, multi-object editing and Prefab overrides.
SerializedProperty is primarily used to read or change the value of a property. It can also iterate through the properties of an object using Next. Additional resources: SerializedObject class, Editor class.
Public Methods
| Method | Description |
|---|---|
| ClearArray | Remove all elements from the array. |
| Copy | Returns a copy of the SerializedProperty iterator in its current state. |
| CountInProperty | Count visible children of this property, including this property itself. |
| CountRemaining | Count remaining visible properties. |
| DeleteArrayElementAtIndex | Delete the element at the specified index in the array. |
| DeleteCommand | Deletes the array element referenced by the SerializedProperty. |
| DuplicateCommand | Duplicates the array element referenced by the SerializedProperty. |
| FindPropertyRelative | Retrieves the SerializedProperty at a relative path to the current property. |
| GetArrayElementAtIndex | Returns the element at the specified index in the array. |
| GetEndProperty | Retrieves the SerializedProperty that defines the end range of this property. |
| GetEnumerator | Retrieves an iterator for enumerating over the visible child properties of the current property. If the property is an array it will enumerate over the array elements. |
| GetFixedBufferElementAtIndex | Returns the element at the specified index in the fixed buffer. |
| InsertArrayElementAtIndex | Insert an new element at the specified index in the array. |
| MoveArrayElement | Move an array element from srcIndex to dstIndex. |
| Next | Move to next property. |
| NextVisible | Move to next visible property. |
| Reset | Move to first property of the object. |
Static Methods
| Method | Description |
|---|---|
| DataEquals | Compares the data for two SerializedProperties. This method ignores paths and SerializedObjects. |
| EqualContents | See if contained serialized properties are equal. |