EditorGUIUtility.ShowObjectPicker
ãã®æ å ±ã¯Unity Documentation Tabsã§ãé²è¦§ãããã¨ãåºæ¥ã¾ã
Unity Documentation Tabsã§é²è¦§ããå ´åã®URLã¯ãã¡ãï¼ENï¼ã¾ãã¯ãã¡ãï¼JPï¼ã§ã
使ãæ¹è¯ããããããã£ãã®ã§ã¡ã¢
é¸æããããªãã¸ã§ã¯ããåå¾ããã«ã¯ EditorGUIUtility.GetObjectPickerObject ã使ç¨ãã¾ã ObjectPickerã®ã¤ãã³ãåå¾ã¯ Event.current.commandName ã§å¤å¥ãè¡ãã¾ã
ObjectSelectorUpdatedã®å ´å
- ObjectPickerå ã§é¸æããããªãã¸ã§ã¯ããå¤æ´ãããæã«å¼ã³åºããã¾ã
ObjectSelectorClosedã®å ´å
- ObjectPickerãéããããæã«å¼ã³åºããã¾ã
using UnityEditor; using UnityEngine; public class Example : EditorWindow { [MenuItem("Window/Example")] static void Do () { GetWindow<Example> (); } Object currentObject = null; Object selectedObject = null; void OnGUI () { //ObjectPickerãéã if (GUILayout.Button ("ShowObjectPicker")) { int controlID = EditorGUIUtility.GetControlID (FocusType.Passive); //Cameraã®ã³ã³ãã¼ãã³ããã¿ãããã¦ããGameObjectãé¸æãã EditorGUIUtility.ShowObjectPicker<Camera> (null, true, "", controlID); } string commandName = Event.current.commandName; if (commandName == "ObjectSelectorUpdated") { currentObject = EditorGUIUtility.GetObjectPickerObject (); //ObjectPickerãéãã¦ããéã¯EditorWindowã®åæç»ãè¡ãããªãã®ã§Repaintãå¼ã³ã ã Repaint (); } else if (commandName == "ObjectSelectorClosed") { selectedObject = EditorGUIUtility.GetObjectPickerObject (); } EditorGUILayout.ObjectField (currentObject, typeof(Object), true); EditorGUILayout.ObjectField (selectedObject, typeof(Object), true); } }