显示工具提示“生成按钮”功能赢得';t运行c#

显示工具提示“生成按钮”功能赢得';t运行c#,c#,unity3d,C#,Unity3d,我已经可以在鼠标悬停在每个按钮上时显示该按钮上的工具提示。但是,按钮功能未运行,但显示了工具提示 代码如下: public static float textHeight = 25; public static float textWidth = 1350; public static float buttonHeight = 25; public static float buttonWidth = 100; public static float sc

我已经可以在鼠标悬停在每个按钮上时显示该按钮上的工具提示。但是,按钮功能未运行,但显示了工具提示

代码如下:

    public static float textHeight = 25;
    public static float textWidth = 1350;
    public static float buttonHeight = 25;
    public static float buttonWidth = 100;
    public static float screenTextHeight = 745;

public virtual void TurnOnGUI()
    {
        Rect buttonRect = new Rect(0, Screen.height - buttonHeight * 3, buttonWidth, buttonHeight);
        Rect tooltipRect = new Rect(100 + 10, Screen.height - buttonHeight * 3 + 5, buttonWidth, buttonHeight);
        Rect textRect = new Rect(10, Screen.height - screenTextHeight, textWidth, textHeight);
        Rect _buttonRect = new Rect(0, Screen.height - buttonHeight * 2, buttonWidth, buttonHeight);
        Rect _buttonRect_ = new Rect(0, Screen.height - buttonHeight * 1, buttonWidth, buttonHeight);
        Rect _tooltipRect = new Rect(100 + 10, Screen.height - buttonHeight * 2 + 5, buttonWidth, buttonHeight);
        Rect _tooltipRect_ = new Rect(100 + 10, Screen.height - buttonHeight * 1 + 5, buttonWidth, buttonHeight);

        label1.normal.textColor = Color.red;

        //Text Field
        if (GUI.Button(textRect, ""))
        {

        }

        //ToolTip Text
        //GUI.Button(buttonRect, new GUIContent("Move", "Move the Player"));
        //GUI.Label(tooltipRect, GUI.tooltip, label1);

        GUI.tooltip = null;
        //Move Button
        if (GUI.Button(buttonRect, "Move"))
        {
            if (!moving)
            {
                GameManager.instance.RemoveTileHighlights();
                moving = true;
                attacking = false;
                GameManager.instance.HighlightTilesAt(gridPosition, Color.blue, movementPerActionPoint);
            }

            else
            {
                moving = false;
                attacking = false;
                GameManager.instance.RemoveTileHighlights();
            }
        }

        //ToolTip Text
        //GUI.Button(_buttonRect, new GUIContent("Attack", "Attack the Player"));
        //GUI.Label(_tooltipRect, GUI.tooltip, label1);

        GUI.tooltip = null;
        //Attack Button
        if (GUI.Button(_buttonRect, "Attack"))
        {
            if (!attacking)
            {
                GameManager.instance.RemoveTileHighlights();
                moving = false;
                attacking = true;
                GameManager.instance.HighlightTilesAt(gridPosition, Color.red, attackRange);
            }

            else
            {
                moving = false;
                attacking = false;
                GameManager.instance.RemoveTileHighlights();
            }
        }

        //ToolTip Text
        //GUI.Button(_buttonRect_, new GUIContent("End Turn", "End Turn the Player"));
        //GUI.Label(_tooltipRect_, GUI.tooltip, label1);

        GUI.tooltip = null;
        //End Turn Button
        if (GUI.Button(_buttonRect_, "End Turn"))
        {
            GameManager.instance.RemoveTileHighlights();
            actionPoints = 2;
            moving = false;
            attacking = false;
            GameManager.instance.NextTurn();
        }
    }
这是屏幕截图(鼠标悬停在“移动”按钮上并显示红色工具提示),工具提示显示,但当我单击“移动”按钮时,它不会运行(不会显示移动的蓝色网格):

但是,当我删除工具提示文本时,“移动”按钮功能运行良好:

我怎样才能解决这个问题?谢谢一个小例子

using UnityEngine;
using System.Collections;

public class Demo : MonoBehaviour {
    bool clicked = false;

    void OnGUI() {
        clicked = GUI.Button(new Rect(10, 10, 100, 20), new GUIContent("Click me", "This is the tooltip"));
        GUI.Label(new Rect(10, 40, 100, 40), GUI.tooltip);
        if(clicked)
        {
        //do your stuff after click 
           print(clicked);
        }
    }
}
i、 e

public static float textHeight = 25;
public static float textWidth = 1350;
public static float buttonHeight = 25;
public static float buttonWidth = 100;
public static float screenTextHeight = 745;

bool move=false,attack=false,endTurn=false;  //Added

public virtual void TurnOnGUI()
{
    Rect buttonRect = new Rect(0, Screen.height - buttonHeight * 3, buttonWidth, buttonHeight);
    Rect tooltipRect = new Rect(100 + 10, Screen.height - buttonHeight * 3 + 5, buttonWidth, buttonHeight);
    Rect textRect = new Rect(10, Screen.height - screenTextHeight, textWidth, textHeight);
    Rect _buttonRect = new Rect(0, Screen.height - buttonHeight * 2, buttonWidth, buttonHeight);
    Rect _buttonRect_ = new Rect(0, Screen.height - buttonHeight * 1, buttonWidth, buttonHeight);
    Rect _tooltipRect = new Rect(100 + 10, Screen.height - buttonHeight * 2 + 5, buttonWidth, buttonHeight);
    Rect _tooltipRect_ = new Rect(100 + 10, Screen.height - buttonHeight * 1 + 5, buttonWidth, buttonHeight);

    label1.normal.textColor = Color.red;

    //Text Field
    if (GUI.Button(textRect, ""))
    {

    }

    //ToolTip Text
    move = GUI.Button(buttonRect, new GUIContent("Move", "Move the Player"));
    GUI.Label(tooltipRect, GUI.tooltip, label1);

    GUI.tooltip = null;
    //Move Button
    if (move)   //edited
    {
        if (!moving)
        {
            GameManager.instance.RemoveTileHighlights();
            moving = true;
            attacking = false;
            GameManager.instance.HighlightTilesAt(gridPosition, Color.blue, movementPerActionPoint);
        }

        else
        {
            moving = false;
            attacking = false;
            GameManager.instance.RemoveTileHighlights();
        }
    }

    //ToolTip Text
    attack = GUI.Button(_buttonRect, new GUIContent("Attack", "Attack the Player"));
    GUI.Label(_tooltipRect, GUI.tooltip, label1);

    GUI.tooltip = null;
    //Attack Button
    if (attack)   //edited
    {
        if (!attacking)
        {
            GameManager.instance.RemoveTileHighlights();
            moving = false;
            attacking = true;
            GameManager.instance.HighlightTilesAt(gridPosition, Color.red, attackRange);
        }

        else
        {
            moving = false;
            attacking = false;
            GameManager.instance.RemoveTileHighlights();
        }
    }

    //ToolTip Text
    endTurn = GUI.Button(_buttonRect_, new GUIContent("End Turn", "End Turn the Player"));
    GUI.Label(_tooltipRect_, GUI.tooltip, label1);

    GUI.tooltip = null;
    //End Turn Button
    if (endTurn)   //edited
    {
        GameManager.instance.RemoveTileHighlights();
        actionPoints = 2;
        moving = false;
        attacking = false;
        GameManager.instance.NextTurn();
    }
}