Example #1
0
        /// <returns>True when button is pressed.</returns>
        private bool OnButtonGUI(Rect rect,
                                 string name,
                                 InspectorGUISkin.ButtonType buttonType,
                                 Event current,
                                 Action onMouseOver)
        {
            using (InspectorGUI.IndentScope.Create(2)) {
                var down = UnityEngine.GUI.Button(rect,
                                                  GUI.MakeLabel(name),
                                                  InspectorEditor.Skin.GetButton(true, buttonType));
                if (current.type == EventType.Repaint &&
                    rect.Contains(current.mousePosition))
                {
                    onMouseOver();
                }

                return(down);
            }
        }
Example #2
0
        public static bool ToolButton(Rect rect,
                                      GUIContent content,
                                      InspectorGUISkin.ButtonType buttonType,
                                      bool active,
                                      bool enabled)
        {
            var disabledScope = new EditorGUI.DisabledScope(!enabled);
            var buttonContent = content.image != null?ToolButtonTooltip(content) : content;

            var pressed = UnityEngine.GUI.Button(rect,
                                                 buttonContent,
                                                 InspectorEditor.Skin.GetButton(active, buttonType));

            if (buttonContent == s_tooltipContent && content.image != null)
            {
                using (IconManager.ForegroundColorBlock(active, enabled))
                    UnityEngine.GUI.DrawTexture(IconManager.GetIconRect(rect), content.image);
            }

            disabledScope.Dispose();

            return(pressed);
        }