Version: 5.4
Method group is Obsolete
Check the docs for the usage of the new parameter 'allowSceneObjects'.

EditorGUILayout.ObjectField

マニュアルに切り替える
public static Object ObjectField (Object obj, Type objType, bool allowSceneObjects, params GUILayoutOption[] options);
public static Object ObjectField (string label, Object obj, Type objType, bool allowSceneObjects, params GUILayoutOption[] options);
public static Object ObjectField (GUIContent label, Object obj, Type objType, bool allowSceneObjects, params GUILayoutOption[] options);

パラメーター

label フィールドのラベル
obj フィールドを表示するオブジェクト
objType 割り当てることができるオブジェクトの型
allowSceneObjects シーンのオブジェクトを割り当てることを許可します。詳しくは Description を参照してください。
options An optional list of layout options that specify extra layout 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 ユーザーによって設定された値

説明

任意のオブジェクトの Type を表示するフィールドを作成します。

オブジェクトをドラッグアンドドロップするか Object Picker を使用してオブジェクトを選択するかのいずれかでオブジェクトを割り当てることができます。

アセットがシーン内のオブジェクトへのリファレンスを格納できないとき、オブジェクトリファレンスがアセットの一部として格納されている場合、 AllowSceneObjects パラメーターが False であることを確認します。

ObjectField がスクリプトコンポーネントのカスタムの Editor の一部の場合、アセットやシーンブジェクトのコンポーネントの場合、チェックするために EditorUtility.IsPersistent() を使用します。

詳細は Editor クラスの例を参照してください。


Search for a help page by selecting the GameObject in the Object Field.

using UnityEditor;
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Object source; [MenuItem("Example/QuickHelper _h")] static void Init() { QuickHelper window = (QuickHelper) EditorWindow.GetWindowWithRect(typeof(QuickHelper), new Rect(0, 0, 165, 100)); window.Show(); } void OnGUI() { EditorGUILayout.BeginHorizontal(); source = EditorGUILayout.ObjectField(source, typeof(Object), true); EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Search!")) if (source == null) ShowNotification(new GUIContent("No object selected for searching")); else if (Help.HasHelpForObject(source)) Help.ShowHelpForObject(source); else Help.BrowseURL("http://forum.unity3d.com/search.php"); } }