Exemplo n.º 1
0
        public static bool WasClicked(Rect rect, int button)
        {
            var clicked = GUIEx.IsHovering(rect) &&
                          Event.current.type == EventType.MouseDown &&
                          Event.current.button == button;

            if (clicked)
            {
                Event.current.Use();
            }
            return(clicked);
        }
Exemplo n.º 2
0
        public static bool ImageButton(Texture2D image, GUIStyle style, params GUILayoutOption[] options)
        {
            Color    color      = Color.black;
            GUIStyle labelStyle = new GUIStyle(style);

            Rect labelRect = GUILayoutUtility.GetRect(new GUIContent(image), style, options);

            if (GUIEx.IsHovering(labelRect))
            {
                color = Color.blue;
            }

            GUIEx.PushColor(color);
            UnityEngine.GUI.DrawTexture(labelRect, image, ScaleMode.ScaleToFit);
            GUIEx.PopColor();

            return(GUIEx.WasClicked(labelRect, 0));
        }
Exemplo n.º 3
0
        public static bool LabelButton(string label, GUIStyle style)
        {
            Color    color      = Color.black;
            GUIStyle labelStyle = new GUIStyle(style);

            Rect labelRect = GUILayoutUtility.GetRect(new GUIContent(label), style);

            if (GUIEx.IsHovering(labelRect))
            {
                color = Color.blue;
            }

            Rect underlineRect = labelRect;

            underlineRect.y      = underlineRect.yMax - 2.0f;
            underlineRect.height = 1.0f;

            labelStyle.normal.textColor = color;
            UnityEngine.GUI.Label(labelRect, label, labelStyle);
            GUIEx.DrawBox(underlineRect, color);

            return(false);
        }
Exemplo n.º 4
0
 public static bool WasClicked(Rect rect)
 {
     return(GUIEx.IsHovering(rect) && Event.current.type == EventType.MouseDown);
 }