public static Rect PopupRect(this Rect r) { return(EditorHelper.PopupRect(r)); }
/// <summary> /// /// </summary> void OnDrawGUI() { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); GUILayout.Label(EditorGUIUtility.IconContent("_Popup"), EditorStyles.toolbarButton, GUILayout.Width(27)); if (EditorHelper.HasMouseClick(GUILayoutUtility.GetLastRect())) { var window = EditorWindow.GetWindow <ObjectBrowserPreference>(true); window.SetTitle(new GUIContent("Preference")); window.m_parentWindow = this; } GUILayout.Label(m_contentTypeList[m_selectTypeList], m_style.ToolbarPopup, GUILayout.Width(160)); if (EditorHelper.HasMouseClick(GUILayoutUtility.GetLastRect())) { EditorUtility.DisplayCustomMenu( EditorHelper.PopupRect(GUILayoutUtility.GetLastRect()), m_contentTypeList, -1, selectMenuItemFunction, Selection.objects); } var _b = GUILayout.Toggle(m_hideFlag, "hideFlags", m_style.toolbarbutton, GUILayout.Width(80)); if (_b != m_hideFlag) { m_hideFlag = _b; onButton_SearchStart(); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); GUIStyle styleListElement = new GUIStyle("PreferencesKeysElement"); bool _select = false; if (m_objList != null) { m_ScrollPos = EditorGUILayout.BeginScrollView(m_ScrollPos); m_objList = m_objList.Where(x => x != null).ToArray(); for (int i = 0; i < m_objList.Length; ++i) { var obj = m_objList[i]; var r = GUILayoutUtility.GetRect(position.width + 1, styleListElement.fixedHeight); if (EditorHelper.HasMouseClick(r)) { //Debug.LogFormat( "hit {0}: {1}: {2}", obj.name, r, m_ScrollPos ); m_selectObjIndex = i; _select = true; Repaint(); } var col = styleListElement.normal.textColor; if (m_selectObjIndex == i) { styleListElement.normal.background = styleListElement.onNormal.background; styleListElement.normal.textColor = styleListElement.onNormal.textColor; } else { styleListElement.normal.background = null; } if (obj != null) { var rofs = r; GUI.Label(r, "", styleListElement); drawBackColor(r, 0x00); rofs.x += 16; GUI.Label(rofs, obj.name, styleListElement); if (AssetDatabase.GetAssetOrScenePath(obj).Contains(".unity")) { rofs.x -= 16; rofs.width = 16; GUI.Label(rofs, "S", styleListElement); } } styleListElement.normal.textColor = col; } EditorGUILayout.EndScrollView(); } if (_select) { forcusObject(m_selectObjIndex); //Selection.activeObject.hideFlags = HideFlags.None; } }