Hello ! I try to use the 4.6 ui system ,what's wrong on my script . Code (JavaScript): import UnityEngine.UI ; import UnityEngine.UI.Text ; public var test : Text ; function Start () { test = GetComponent.<Text>() ; } function Update () { test = "caca" ; } Cannot convert 'String' to 'UnityEngine.UI.Text'. thanks
Code (JavaScript): import UnityEngine.UI ; import UnityEngine.UI.Text ; public var test : Text ; function Start () { test = GetComponent.<Text>() ; } function Update () { test.text = "caca" ; }
Since you're using Javascript / Unityscript use... Code (JavaScript): GetComponent(Text); Notice there is no fullstop between GetComponent and the brackets. Also the type is provided within the brackets. <> generics is used for C# GetComponent. http://docs.unity3d.com/ScriptReference/GameObject.GetComponent.html