- BeginHorizontal
- BeginScrollView
- BeginToggleGroup
- BeginVertical
- BoundsField
- ColorField
- CurveField
- EndHorizontal
- EndScrollView
- EndToggleGroup
- EndVertical
- EnumPopup
- FloatField
- Foldout
- InspectorTitlebar
- IntField
- IntPopup
- IntSlider
- LabelField
- LayerField
- MinMaxSlider
- ObjectField
- PasswordField
- Popup
- PrefixLabel
- PropertyField
- RectField
- SelectableLabel
- Slider
- Space
- TagField
- TextArea
- TextField
- Toggle
- Vector2Field
- Vector3Field
- Vector4Field
EditorGUILayout.ObjectField 物体字段
static function ObjectField (obj : Object, objType : System.Type, allowSceneObjects : boolean, params options : GUILayoutOption[]) : Object
static function ObjectField (label : String, obj : Object, objType : System.Type, allowSceneObjects : boolean, params options : GUILayoutOption[]) : Object
static function ObjectField (label : GUIContent, obj : Object, objType : System.Type, allowSceneObjects : boolean, params options : GUILayoutOption[]) : Object
Parameters参数
-
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.
允许指定场景物体。 -
optionsAn optional list of layout options that specify extra layouting properties. Any values passed in here will override settings defined by the style. See Also: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
指定额外布局属性的可选列表。这里传递任意值,将覆盖样式定义的设置。
Object - The object that has been set by the user.
返回Object,由用户设置的物体。
Description描述
Make an object field. You can assign objects either by drag'n 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()来检查。
Search for a help page by selecting the GameObject in the Object Field.
搜索在这个物体字段选择的物体帮助页面。
// EditorScript that quickly searchs for a help page
// of the selected Object.
//搜索选择物体的帮助页面
// If there is no page found on the Manual it opens the Unity forum.
//如果没有发现页面,将打开Unity论坛
import UnityEditor;
class QuickHelper extends EditorWindow {
var source : Object;
@MenuItem("Example/QuickHelper _h")
static function Init() {
var window : QuickHelper = EditorWindow.GetWindowWithRect(QuickHelper, Rect(0,0,165,100));
window.Show();
}
function OnGUI() {
EditorGUILayout.BeginHorizontal();
source = EditorGUILayout.ObjectField(source, Object);
EditorGUILayout.EndHorizontal();
if(GUILayout.Button("Search!")) {
if(source == null) {
this.ShowNotification(GUIContent("No object selected for searching"));
} else {
if(Help.HasHelpForObject(source))
Help.ShowHelpForObject(source);
else
Help.BrowseURL("http://forum.unity3d.com/search.php");
}
}
}
}