- actionKey
- BoundsField
- ColorField
- CurveField
- DrawPreviewTexture
- DrawTextureAlpha
- DropShadowLabel
- EnumPopup
- FloatField
- Foldout
- indentLevel
- InspectorTitlebar
- IntField
- IntPopup
- IntSlider
- LabelField
- LayerField
- MinMaxSlider
- ObjectField
- PasswordField
- Popup
- PrefixLabel
- ProgressBar
- PropertyField
- RectField
- SelectableLabel
- Slider
- TagField
- TextArea
- TextField
- Toggle
- Vector2Field
- Vector3Field
- Vector4Field
EditorGUI.ObjectField 物体字段
static function ObjectField (position : Rect, obj : Object, objType : System.Type, allowSceneObjects : boolean) : Object
static function ObjectField (position : Rect, label : String, obj : Object, objType : System.Type, allowSceneObjects : boolean) : Object
static function ObjectField (position : Rect, label : GUIContent, obj : Object, objType : System.Type, allowSceneObjects : boolean) : Object
Parameters参数
- positionRectangle on the screen to use for the field.
屏幕上的矩形区域 - labelOptional label in front of the field.
该字段前面的可选标签 -
objThe object the field shows. // 字段显示的物体
- objTypeThe type of the object. // 物体的类型
-
allowSceneObjectsAllow assigning scene objects. See Description for more info.
允许指定场景物体。
Object - The object that has been set by the user.
返回Object - 用户设置的对象。
Description描述
Make an object field. You can assign objects either by drag and drop objects or by selecting an object using the Object Picker.
制作一个物体字段。可以指定物体无论是通过拖拽物体或通过物体拾取器选择物体。
Ensure that the allowSceneObjects parameter is false if the object reference is stored as part of an asset, since assets can't store references to objects in a scene.
如果物体引用作为资源的一部分储存,确保allowSceneObjects参数为假。因为资源不能存储在一个场景中的对象的引用。
If the ObjectField is part of a custom Editor for a script component, use EditorUtility.IsPersistent() to check if the component is on an asset or a scene object.
See example in Editor class.
如果ObjectField用于一个脚本组件自定义编辑器的一部分,如果组件在一个资源或场景物体,使用EditorUtility.IsPersistent()来检查。
Object field in an Editor Window.
在编辑器窗口中的对象字段。
//Select the dependencies of the found GameObject
//管理选择找到的游戏对象
class EditorGUIObjectField extends EditorWindow {
var obj : GameObject = null;
@MenuItem("Examples/Select Dependencies")
static function Init() {
var window = GetWindow(EditorGUIObjectField);
window.position = Rect(0, 0, 250, 80);
window.Show();
}
function OnInspectorUpdate() {
Repaint();
}
function OnGUI() {
obj = EditorGUI.ObjectField(Rect(3,3,position.width - 6, 20),
"Find Dependency",
obj,
GameObject);
if(obj) {
if(GUI.Button(Rect(3,25,position.width - 6, 20), "Check Dependencies"))
Selection.objects = EditorUtility.CollectDependencies([obj]);
} else {
EditorGUI.LabelField(Rect(3,25,position.width - 6,20),
"Missing:",
"Select an object first");
}
}
}