SerializedProperty

class in UnityEditor

Cambiar al Manual

Descripción

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

Variables

animationCurveValueValue of a animation curve property.
arrayElementTypeType name of the element in an array property. (Read Only)
arraySizeThe 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.
boolValueValue of a boolean property.
boundsIntValueValue of bounds with integer values property.
boundsValueValue of bounds property.
colorValueValue of a color property.
depthNesting depth of the property. (Read Only)
displayNameNice display name of the property. (Read Only)
doubleValueValue of a float property as a double.
editableIs this property editable? (Read Only)
enumDisplayNamesDisplay-friendly names of enumeration of an enum property.
enumNamesNames of enumeration of an enum property.
enumValueIndexEnum index of an enum property.
exposedReferenceValueA reference to another Object in the Scene. This reference is resolved in the context of the SerializedObject containing the SerializedProperty.
fixedBufferSizeThe number of elements in the fixed buffer. (Read Only)
floatValueValue of a float property.
hasChildrenDoes it have child properties? (Read Only)
hasMultipleDifferentValuesDoes this property represent multiple different values due to multi-object editing? (Read Only)
hasVisibleChildrenDoes it have visible child properties? (Read Only)
intValueValue of an integer property.
isArrayIs this property an array? (Read Only)
isDefaultOverrideAllows you to check whether his property is a default override.Certain properties on Prefab instances are default overrides.See PrefabUtility.IsDefaultOverride for more information.
isExpandedIs this property expanded in the inspector?
isFixedBufferIs this property a fixed buffer? (Read Only)
isInstantiatedPrefabIs property part of a Prefab instance? (Read Only)
longValueValue of a integer property as a long.
nameName of the property. (Read Only)
objectReferenceValueValue of an object reference property.
prefabOverrideAllows you to check whether a property's value is overriden (i.e. different to the Prefab it belongs to).
propertyPathFull path of the property. (Read Only)
propertyTypeType of this property (Read Only).
quaternionValueValue of a quaternion property.
rectIntValueValue of a rectangle with integer values property.
rectValueValue of a rectangle property.
serializedObject SerializedObject this property belongs to (Read Only).
stringValueValue of a string property.
tooltipTooltip of the property. (Read Only)
typeType name of the property. (Read Only)
vector2IntValueValue of a 2D integer vector property.
vector2ValueValue of a 2D vector property.
vector3IntValueValue of a 3D integer vector property.
vector3ValueValue of a 3D vector property.
vector4ValueValue of a 4D vector property.

Funciones Públicas

ClearArrayRemove all elements from the array.
CopyReturns 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.
CountInPropertyCount visible children of this property, including this property itself.
CountRemainingCount remaining visible properties.
DeleteArrayElementAtIndexDelete the element at the specified index in the array.
DeleteCommandDeletes the serialized property.
DuplicateCommandDuplicates the serialized property.
FindPropertyRelativeRetrieves the SerializedProperty at a relative path to the current property.
GetArrayElementAtIndexReturns the element at the specified index in the array.
GetEndPropertyRetrieves the SerializedProperty that defines the end range of this property.
GetEnumeratorRetrieves an iterator that allows you to iterator over the current nexting of a serialized property.
GetFixedBufferElementAtIndexReturns the element at the specified index in the fixed buffer.
InsertArrayElementAtIndexInsert an empty element at the specified index in the array.
MoveArrayElementMove an array element from srcIndex to dstIndex.
NextMove to next property.
NextVisibleMove to next visible property.
ResetMove to first property of the object.

Funciones Estáticas

DataEqualsCompares the data for two SerializedProperties. This method ignores paths and SerializedObjects.
EqualContentsSee if contained serialized properties are equal.