Exemplo n.º 1
0
        public override void OnGUI(Rect rect)
        {
            EditorGUI.DrawRect(rect, Color.white * 0.9f);
            EditorGUILayout.GetControlRect(GUILayout.Height(VERTICAL_PADDING));
            for (int i = 0; i < Items.Count; ++i)
            {
                if (Items[i].isSeparator)
                {
                    EditorCommon.Separator();
                    continue;
                }
                GUI.enabled = !Items[i].isDisabled;
                EditorGUILayout.BeginHorizontal();
                Rect itemRect = EditorGUILayout.GetControlRect(GUILayout.Height(EditorCommon.standardHeight));
                if (itemRect.Contains(Event.current.mousePosition))
                {
                    EditorGUI.DrawRect(itemRect, EditorCommon.selectedItemColor);
                }

                Rect checkmarkRect = new Rect(itemRect.min.x, itemRect.min.y, itemRect.height, itemRect.height);
                if (Items[i].isOn)
                {
                    GUIContent icon = EditorGUIUtility.IconContent(CHECK_MARK_ICON_PATH);
                    EditorGUI.LabelField(checkmarkRect, icon);
                }

                Rect buttonRect = new Rect(itemRect.min.x + itemRect.height, itemRect.min.y, itemRect.width - itemRect.height, itemRect.height);
                if (GUI.Button(buttonRect, Items[i].content, GUIStyle.none))
                {
                    InvokeAction(Items[i].action);
                    editorWindow.Close();
                }
                EditorGUILayout.EndHorizontal();
                GUI.enabled = true;
            }

            EditorGUILayout.GetControlRect(GUILayout.Height(VERTICAL_PADDING));

            if (Event.current.type == EventType.MouseMove)
            {
                editorWindow.Repaint();
            }
        }