`UnityEngine.UI.Text' does not contain a definition for `Text'

Context: I am making a 2d platforming game ive created a canvas it has a Text script attached, it shows in game. The piece of code bellow cant find the Text type used by the canvas . (im new to this stuff its assignment work an this has stopped me) Unity cant find the ‘definition for Text type’ even though i am using UnityEngine.UI i don’t know what to do.

(ScoreManager.cs)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ScoreManager : MonoBehaviour {

public Text scoreText;

public float scoreCount;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
scoreText.Text = "Food: " + scoreCount;
}
}

(Pickup.cs)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Pickup : MonoBehaviour {

public int scoreToGive;

private ScoreManager theScoreManager;

void Start () {
theScoreManager = FindObjectOfType();
}

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

void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.name == “CharacterRobotBoy”)
{
theScoreManager.scoreCount += scoreToGive;
Destroy(gameObject);
}
}
}

Please use code tags when posting code.

// Correct use is:
scoreText.text
// Not:
scoreText.Text

IntelliSense is your friend. MonoDevelop and Visual Studio show possible matches as you type, in the case of VS it’s activated with ctrl + space.

1 Like

thanks dude, i was using unity collabe and my friend said it was working and it turned out it was my client and so reinstalled and it worked so i dont know :slight_smile:

1 Like

Well, that is bizzare. I’ve never used Collaborate, perhaps there was some error-correcting going on. Instances of Text don’t have a “Text” field.

using UnityEngine.UI; //<<<<<< Using

public Text myText; //<<<<<<< my UI text

    void Update (){
     
        myText.text ="Hello World"+"\r\n im cody";
      //new line, \r MacOS, \n UnixOS, \r\n WinOS//
    }