SerializedProperty と SerializedObject は、例えばプレハブの UI の Undo とスタイリングを自動的に処理する一般的な方法として、オブジェクトのプロパティーを編集するためのクラスです。
SerializedProperty は主に SerializedObject と Editor クラスを組み合わせて使用します。 参照: SerializedObject クラス、 Editor クラス
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 | アニメーションカーブのプロパティーの値 |
| arrayElementType | Type name of the element in an array property. (Read Only) |
| arraySize | 配列内の要素数 SerializedObject に複数のオブジェクトが含まれている場合、最も小さい要素数を返します。よって、いつでも SerializedObject を通してイテレートすることと、すべてのオブジェクトで get プロパティーだけを探すことが可能です。 |
| boolValue | boolean プロパティーの値 |
| boundsIntValue | Value of bounds with integer values property. |
| boundsValue | Bounds プロパティーの値 |
| colorValue | color プロパティーの値 |
| depth | プロパティーのネストの深さ (読み取り専用) |
| displayName | 最適なプロパティーの表示名 (読み取り専用) |
| doubleValue | double として float プロパティーの値 |
| editable | プロパティーが編集可能かどうか (読み取り専用) |
| enumDisplayNames | enum プロパティーの表示しやすい列挙型名 |
| enumNames | enum プロパティーの列挙型名 |
| enumValueIndex | enum プロパティーの enum インデックス |
| 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 | float プロパティーの値 |
| hasChildren | 子のプロパティーを持つかどうか (読み取り専用) |
| hasMultipleDifferentValues | このプロパティーは複数編集のため、複数の異なる値を持っているかどうか (読み取り専用) |
| hasVisibleChildren | Visible の子のプロパティーを持つかどうか (読み取り専用) |
| intValue | 整数のプロパティーの値 |
| isArray | プロパティーが配列かどうか (読み取り専用) |
| isExpanded | インスペクター上でこのプロパティーを展開するかどうか (読み取り専用) |
| isFixedBuffer | Is this property a fixed buffer? (Read Only) |
| isInstantiatedPrefab | プレハブインスタンスのプロパティーの一部かどうか (読み取り専用) |
| longValue | Long としての整数のプロパティーの値 |
| name | プロパティー名 (読み取り専用) |
| objectReferenceValue | 参照オブジェクトのプロパティーの値 |
| prefabOverride | プロパティーの値がプレハブに保存されている値と異なるかどうか |
| propertyPath | プロパティーのフルパス (読み取り専用) |
| propertyType | プロパティーのタイプ (読み取り専用) |
| quaternionValue | Quaternion プロパティーの値 |
| rectIntValue | Value of a rectangle with integer values property. |
| rectValue | Rect プロパティーの値 |
| serializedObject | SerializedObject this property belongs to (Read Only). |
| stringValue | string プロパティーの値 |
| tooltip | プロパティーのツールチップ (読み取り専用) |
| type | プロパティーのタイプ名 (読み取り専用) |
| vector2IntValue | Value of a 2D integer vector property. |
| vector2Value | Vector2 プロパティーの値 |
| vector3IntValue | Value of a 3D integer vector property. |
| vector3Value | Vector3 プロパティーの値 |
| vector4Value | Vector4 プロパティーの値 |
| ClearArray | 配列からすべてのエレメントを削除します |
| Copy | 現在の状態の SerializedProperty イテレーターのコピーを返し、現在のプロパティーへの参照を維持しますが、イテレーションを続行する場合に便利です。 |
| CountInProperty | このプロパティー自体を含む、このプロパティーの Visible children (見えている子) をカウントします |
| CountRemaining | 残りの Visible プロパティーをカウントします |
| DeleteArrayElementAtIndex | 配列内の指定したインデックスにあるエレメントを削除します |
| DeleteCommand | シリアライズされたプロパティーを削除します |
| DuplicateCommand | シリアライズされたプロパティーを複製します |
| FindPropertyRelative | 現在のプロパティーへの相対パスで SerializedProperty を取得してきます |
| GetArrayElementAtIndex | 配列内の指定したインデックスにあるエレメントを返します |
| GetEndProperty | このプロパティーの範囲の終わりを定義する SerializedProperty を取得します |
| GetEnumerator | 現在のシリアライズされたプロパティーの Next() を反復処理するイテレータを取得します |
| GetFixedBufferElementAtIndex | Returns the element at the specified index in the fixed buffer. |
| InsertArrayElementAtIndex | 空のエレメントを配列内の指定したインデックスに挿入します |
| MoveArrayElement | srcIndex から dstIndex に配列エレメントを移動します |
| Next | 次のプロパティーに移動します |
| NextVisible | 次の Visible プロパティーに移動します |
| Reset | オブジェクトの最初のプロパティーに移動します |
| EqualContents | 2つの SerializedProperty が等しいかどうかを確認します。 |