inspector中实现列表框:
public override void OnInspectorGUI(){
bool isDoubleClick=false;
Event e = Event.current;
if (e.type == EventType.mouseDown && Event.current.button == 0) {//left button down
if(e.clickCount==2){//double click
isDoubleClick=true;
}
}//got isDoubleClick
Rect scrollviewRect=EditorGUILayout.BeginVertical ();
{
scrollPosition = EditorGUILayout.BeginScrollView (scrollPosition, "box", GUILayout.Height (150));
{
//ref: http://answers.unity3d.com/questions/37223/how-do-i-center-a-gui-label.html
//ref: http://iaimstar.iteye.com/blog/2222128
GUIStyle _style = GUI.skin.GetStyle ("MenuItemMixed");
m_selectIndex = GUILayout.SelectionGrid (m_selectIndex, list.ToArray (), 1, _style);
}
EditorGUILayout.EndScrollView ();
if (scrollviewRect.Contains (e.mousePosition)) {
if(isDoubleClick){
Debug.Log(list[m_selectIndex]);
}
}
}
EditorGUILayout.EndVertical ();
}