无法将类型“字符串”隐式转换为“ UnityEngine.UI.Text”

时间:2018-09-23 13:27:57

标签: string user-interface text

控制台告诉我:

cannot implicitly convert type `string' to `UnityEngine.UI.Text'

我正在尝试做到这一点,以便在使用UI应用效果(单击“应用”按钮)时,我的“金额”下降。

int moneyamount;
int isApplied;

public Text moneyAmountText;
public Text effectPrice;

public Button buybutton;

// Use this for initialization
void Start () {
    moneyamount = PlayerPrefs.GetInt ("MoneyAmount");   
}

// Update is called once per frame
void Update () {

    moneyAmountText = "Money: " + moneyamount.ToString () + "$";

    isApplied = PlayerPrefs.GetInt ("isApplied");

    if (moneyamount >= 5 && isApplied == 0)
        buybutton.interactable = true;
    else
        buybutton.interactable = false;

}

public void applyeff()
{
    moneyamount -= 5;
    PlayerPrefs.SetInt ("isApplied", 1);
}

0 个答案:

没有答案