- animationCurveValue
- boolValue
- boundsValue
- colorValue
- Copy
- CountRemaining
- DeleteCommand
- depth
- DuplicateCommand
- editable
- enumNames
- enumValueIndex
- EqualContents
- floatValue
- hasChildren
- hasVisibleChildren
- intValue
- isExpanded
- isInstantiatedPrefab
- name
- NextVisible
- Next
- objectReferenceValue
- prefabOverride
- propertyPath
- propertyType
- rectValue
- Reset
- serializedObject
- stringValue
- tooltip
- type
- vector2Value
- vector3Value
SerializedProperty 序列化属性
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和SerializedObject类用于对象编辑器属性,是完全通用的方法,自动处理撤销和为预设的UI样式。
Note: This is an editor class. To use it you have to place your script in Assets/Editor inside your project folder. Editor classes are in the UnityEditor namespace so for C# scripts you need to add "using UnityEditor;" at the beginning of the script.
注意:这是一个编辑器类,如果想使用它你需要把它放到工程目录下的Assets/Editor文件夹下。编辑器类在UnityEditor命名空间下。所以当使用C#脚本时,你需要在脚本前面加上 "using UnityEditor"引用。
SerializedProperty is used in conjunction with SerializedObject and Editor classes.
SerializedProperty与SerializedObject和Editor类配合使用。
// C# example: A custom Inspector for Transform components.
//自定义Transform组件的检视面板
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(Transform))]
public class TransformInspector : Editor {
SerializedObject m_Object;
SerializedProperty m_Property;
void OnEnable () {
m_Object = new SerializedObject (target);
m_Property = m_Object.FindProperty ("m_LocalPosition.x");
}
void OnInspectorGUI () {
// Grab the latest data from the object
//从对象抓取的最新数据
m_Object.Update ();
// Editor UI for the property
//属性的编辑器界面
EditorGUILayout.PropertyField (m_Property);
// Apply the property, handle undo
//应用属性,撤销
m_Object.ApplyModifiedProperties ();
}
}
Variables变量
-
SerializedObject this property belongs to (Read Only).
这个属性属于SerializedObject(只读)。 -
Name of the property (Read Only)
属性的名称(只读)。 -
Type name of the property (Read Only)
属性的类型名称(只读)。 -
Tooltip of the property (Read Only)
属性的工具提示(只读)。 -
Nesting depth of the property (Read Only)
属性的嵌套深度(只读)。 -
Full path of the property (Read Only)
属性的完整路径(只读)。 -
Is this property editable? (Read Only)
属性可编辑么(只读)? -
Is this property expanded in the inspector?
在检视面板属性是否扩展? -
Does it have child properties? (Read Only)
是否有子属性?(只读) -
Does it have visible child properties? (Read Only)
是否有可见的子属性?(只读) -
Is property part of a prefab instance? (Read Only)
属性是一个预设实例的一部分?(只读) -
Is property's value different from the prefab it belongs to?
预设属性的值是否不同? -
Type of this property (Read Only). // 该属性的类型(只读)。
-
Value of an integer property. // 整数属性值。
-
Value of a boolean property. // 布尔属性值。
-
Value of a float property. // 浮点数属性值。
-
Value of a string property. // 字符串属性值。
-
Value of a color property. // 颜色属性值。
-
Value of a animation curve property. // 动画曲线属性值。
-
Value of an object reference property. // 物体引用属性值。
-
Enum index of an enum property. // 一个枚举属性的枚举索引。
-
Names of enumeration of an enum property.
一个枚举属性的枚举名称数组。 -
Value of a 2D vector property. // 一个2D向量属性的值。
-
Value of a 3D vector property. // 一个3D向量属性的值。
-
Value of a rectangle property. // 一个矩形属性值。
-
Value of bounds property. // 边界盒属性的值。
Functions函数
-
Move to next property. // 移动到下一个属性。
-
Move to next visible property. // 移动到下一个可见属性。
-
Move to first property of the object. // 移动到对象的第一个属性。
-
Count remaining visible properties. // 计算余下的可见属性。
-
Duplicates the SerializedProperty. // 复制SerializedProperty。
-
复制命令。
-
删除命令。
Class Functions类函数
-
See if contained serialized properties are equal.
看是否包含序列化的属性是相等的。