Type 'Text' does not contain a definition for 'text'

From what i have seen of examples changing text should be pretty straight forward but for some reason the ‘text’ parameter doesnt show up for my ‘Text’ type variables?
I am using UnityEngine.UI,

GameObject Slot11 = new GameObject ("Slot1");
 Slot11.transform.SetParent (this.transform);
Text myText = Slot11.AddComponent<Text> ();
myText.text= "nice";

That last line of code is where it says there’s a problem and that ‘text’ doesnt exist.

Am i using an outdate version UnityEngine.UI or something? I have been at this for quite a while now and it feels silly to have so much trouble over Text of all things.

Here’s the full error:
“Assets/Scripts/Showing4.cs(65,12): error CS1061: Type Text' does not contain a definition for text’ and no extension method text' of type Text’ could be found. Are you missing an assembly reference?”


Well, in 99.9% of all cases where a built-in component suddenly doesn’t have the members it should have, you usually have created a custom class with the same name. The global namespace always takes precedence over other namespaces.

The best solution is to avoid naming your classes the same as built-in components. However if you want to do that, you have to use the full classname whenever you use that type:

UnityEngine.UI.Text myText = Slot11.AddComponent<UnityEngine.UI.Text>();