コード例 #1
0
    public bool IsClicked()
    {
        GUI.depth = layer;

        GUIContent content;

        if (!image)
        {
            content = new GUIContent(text, tooltip.Description.Text);
        }
        else if (string.IsNullOrEmpty(text))
        {
            content = new GUIContent(image, tooltip.Description.Text);
        }
        else
        {
            content = new GUIContent(image + text, tooltip.Description.Text);
        }

        Rect rectangle = new Rect(position.x, position.y, dimensions.x, dimensions.y);
        bool value     = GUI.Button(rectangle, content);

        // Draw the tooltip at the specified position.
        if (GUI.tooltip != "" &&
            GUI.tooltip == tooltip.Description.Text)
        {
            tooltip.DrawMe();
        }

        return(value);
    }
コード例 #2
0
    /// <summary>
    /// Determines whether the button is clicked.
    /// </summary>
    /// <returns><c>true</c> if this instance is clicked; otherwise, <c>false</c>.</returns>
    public bool IsClicked()
    {
        if (Image == null)
        {
            return(false);
        }

        if (!IsInteractable)
        {
            return(false);
        }

        GUI.depth = Layer;
        GUI.color = Tint;
        Rect buttonRect = GetElementRect(Dimensions);

        bool result = GUI.Button(buttonRect, new GUIContent(Image, Tooltip.Description.Text));

        // Draw the tooltip.
        if (GUI.tooltip == Tooltip.Description.Text &&
            !string.IsNullOrEmpty(GUI.tooltip))
        {
            Tooltip.DrawMe();
        }

        return(result);
    }
コード例 #3
0
    public bool IsClicked()
    {
        if (string.IsNullOrEmpty(Text))
        {
            throw new ArgumentException("Checkboxes require text to be shown.");
        }

        if (!IsInteractable)
        {
            return(false);
        }

        GUI.depth = Layer;
        GUI.color = Tint;

        Rect checkRect = GetElementRect(Dimensions);

        if (Tooltip != null)
        {
            Value = GUI.Toggle(checkRect, Value, new GUIContent(Text, Tooltip.Description.Text));

            // Draw the tooltip.
            if (GUI.tooltip == Tooltip.Description.Text &&
                !string.IsNullOrEmpty(GUI.tooltip))
            {
                Tooltip.DrawMe();
            }
        }
        else
        {
            Value = GUI.Toggle(checkRect, Value, Text);
        }

        return(true);
    }
コード例 #4
0
    /// <summary>
    /// Determines whether the button has been clicked.
    /// </summary>
    /// <returns>
    /// <c>true</c> if this instance is clicked; otherwise, <c>false</c>.
    /// </returns>
    public bool IsClicked()
    {
        if (ButtonText == null)
        {
            throw new ArgumentException("Buttons require text to be shown.");
        }

        if (!IsInteractable)
        {
            return(false);
        }

        GUI.depth = Layer;
        GUI.color = Tint;
        Rect buttonRect = GetElementRect(Dimensions);

        bool result;

        if (Tooltip != null)
        {
            result = GUI.Button(buttonRect, new GUIContent(ButtonText, Tooltip.Description.Text));

            // Draw the tooltip.
            if (GUI.tooltip == Tooltip.Description.Text &&
                !string.IsNullOrEmpty(GUI.tooltip))
            {
                Tooltip.DrawMe();
            }
        }
        else
        {
            result = GUI.Button(buttonRect, ButtonText);
        }

        return(result);
    }