SerializedProperty and SerializedObject are classes for editing properties on objects in a completely generic way that automatically handles undo and styling UI for prefabs.
SerializedProperty is used in conjunction with SerializedObject and Editor classes. See Also: SerializedObject class, Editor class.
using UnityEngine; using UnityEditor;
public class MyObject : ScriptableObject { public int myInt = 42; }
public class SerializedPropertyTest : MonoBehaviour { void Start() { MyObject obj = ScriptableObject.CreateInstance<MyObject>(); SerializedObject serializedObject = new UnityEditor.SerializedObject(obj);
SerializedProperty serializedPropertyMyInt = serializedObject.FindProperty("myInt");
Debug.Log("myInt " + serializedPropertyMyInt.intValue); } }
animationCurveValue | Value of a animation curve property. |
arrayElementType | Type name of the element in an array property. (Read Only) |
arraySize | The number of elements in the array. If the SerializedObject contains multiple objects it will return the smallest number of elements. So it is always possible to iterate through the SerializedObject and only get properties found in all objects. |
boolValue | Value of a boolean property. |
boundsValue | Value of bounds property. |
colorValue | Value of a color property. |
depth | Nesting depth of the property. (Read Only) |
displayName | Nice display name of the property. (Read Only) |
doubleValue | Value of a float property as a double. |
editable | Is this property editable? (Read Only) |
enumDisplayNames | Display-friendly names of enumeration of an enum property. |
enumNames | Names of enumeration of an enum property. |
enumValueIndex | Enum index of an enum property. |
exposedReferenceValue | A reference to another Object in the Scene. This reference is resolved in the context of the SerializedObject containing the SerializedProperty. |
fixedBufferSize | The number of elements in the fixed buffer. (Read Only) |
floatValue | Value of a float property. |
hasChildren | Does it have child properties? (Read Only) |
hasMultipleDifferentValues | Does this property represent multiple different values due to multi-object editing? (Read Only) |
hasVisibleChildren | Does it have visible child properties? (Read Only) |
intValue | Value of an integer property. |
isArray | Is this property an array? (Read Only) |
isExpanded | Is this property expanded in the inspector? |
isFixedBuffer | Is this property a fixed buffer? (Read Only) |
isInstantiatedPrefab | Is property part of a prefab instance? (Read Only) |
longValue | Value of a integer property as a long. |
name | Name of the property. (Read Only) |
objectReferenceValue | Value of an object reference property. |
prefabOverride | Is property's value different from the prefab it belongs to? |
propertyPath | Full path of the property. (Read Only) |
propertyType | Type of this property (Read Only). |
quaternionValue | Value of a quaternion property. |
rectValue | Value of a rectangle property. |
serializedObject | SerializedObject this property belongs to (Read Only). |
stringValue | Value of a string property. |
tooltip | Tooltip of the property. (Read Only) |
type | Type name of the property. (Read Only) |
vector2Value | Value of a 2D vector property. |
vector3Value | Value of a 3D vector property. |
vector4Value | Value of a 4D vector property. |
ClearArray | Remove all elements from the array. |
Copy | Returns a copy of the SerializedProperty iterator in its current state. This is useful if you want to keep a reference to the current property but continue with the iteration. |
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 serialized property. |
DuplicateCommand | Duplicates the serialized property. |
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 that allows you to iterator over the current nexting of a serialized property. |
GetFixedBufferElementAtIndex | Returns the element at the specified index in the fixed buffer. |
InsertArrayElementAtIndex | Insert an empty 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. |
EqualContents | See if contained serialized properties are equal. |