SerializedObject and SerializedProperty are classes for editing properties on objects in a completely generic way that automatically handles undo and styling UI for prefabs.
SerializedObject is used in conjunction with SerializedProperty and Editor classes.
See Also: SerializedProperty class, Editor class.
#pragma strict public class MyObject extends ScriptableObject { public var myInt: int = 42; } public class SerializedPropertyTest extends MonoBehaviour { function Start() { var obj: MyObject = ScriptableObject.CreateInstance.<MyObject>(); var serializedObject: SerializedObject = new UnityEditor.SerializedObject(obj); var serializedPropertyMyInt: UnityEditor.SerializedProperty = serializedObject.FindProperty("myInt"); Debug.Log("myInt " + serializedPropertyMyInt.intValue); } }
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);
UnityEditor.SerializedProperty serializedPropertyMyInt = serializedObject.FindProperty("myInt");
Debug.Log("myInt " + serializedPropertyMyInt.intValue); } }
context | The context used to store and resolve ExposedReference types. This is set by the SerializedObject constructor. |
isEditingMultipleObjects | Does the serialized object represents multiple objects due to multi-object editing? (Read Only) |
maxArraySizeForMultiEditing | Defines the maximum size beyond which arrays cannot be edited when multiple objects are selected. |
targetObject | The inspected object (Read Only). |
targetObjects | The inspected objects (Read Only). |
SerializedObject | Create SerializedObject for inspected object. |
ApplyModifiedProperties | Apply property modifications. |
ApplyModifiedPropertiesWithoutUndo | Applies property modifications without registering an undo operation. |
CopyFromSerializedProperty | Copies a value from a SerializedProperty to the corresponding serialized property on the serialized object. |
CopyFromSerializedPropertyIfDifferent | Copies a changed value from a SerializedProperty to the corresponding serialized property on the serialized object. |
FindProperty | Find serialized property by name. |
GetIterator | Get the first serialized property. |
SetIsDifferentCacheDirty | Update hasMultipleDifferentValues cache on the next /Update()/ call. |
Update | Update serialized object's representation. |
UpdateIfRequiredOrScript | Update serialized object's representation, only if the object has been modified since the last call to Update or if it is a script. |