unity, inspector listview
Posted wantnon
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了unity, inspector listview相关的知识,希望对你有一定的参考价值。
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 ();
}
以上是关于unity, inspector listview的主要内容,如果未能解决你的问题,请参考以下文章