I came from Unreal Engine 4. I created a script, and I keep getting an error:

Assets/scripts/UpgradeManager.cs(17,18): error CS1061: Type `UnityEngine.UI.Text' does not contain a definition for `Text' and no extension method `Text' of type `UnityEngine.UI.Text' could be found (are you missing a using directive or an assembly reference?)

My code is:

using UnityEngine;
using System.Collections;


public class UpgradeManager : MonoBehaviour {

    public Click click;
    public UnityEngine.UI.Text iteminfo;
    public float cost;
    public int count = 0;
    public int clickpower;
    public string itemName;
    public float _newCost;

    void Update()
    {
        iteminfo.Text = itemName + "/nCost: " + cost + "/nPower: +" + clickpower;
    }

    public void PurchaseUpgrade()
    {
        if (click.money >= cost) 
        {
            click.money -= cost;
            count += 1;
            click.moneyperclick += clickpower;
            cost = Mathf.Round(cost * 1.15f);
            _newCost = Mathf.Pow(cost, _newCost = cost);
        }

    }
}
share|improve this question

closed as off-topic by Alexandre Vaillancourt, Josh Petrie May 31 '16 at 17:53

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Programming questions that aren't specific to game development are off-topic here, but can be asked on Stack Overflow. A good rule of thumb is to ask yourself "would a professional game developer give me a better/different/more specific answer to this question than other programmers?"" – Alexandre Vaillancourt, Josh Petrie
If this question can be reworded to fit the rules in the help center, please edit the question.

2  
For future use of this site, remember: 1. Read your error messages and follow up on what they tell you - in this case, a visit to the docs would have shown you that there is indeed no Text property here, and that the correct spelling is text, all lowercase. 2. "I need help with my game" describes EVERY post on this site, so it's never useful as a title. Always make your title descriptive of what your actual problem is, so people who know how to solve it, or others with the same problem, can find it. 3. Use the post preview to ensure your code is formatted correctly. – DMGregory May 29 '16 at 12:39

Identifiers in C# are case sensitive. You want iteminfo.text not iteminfo.Text

You can verify in the docs that the UnityEngine.UI.Text.text property is all-lowercase.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.