- Home /
 
BCE0019: 'text' is not a member of UnityEngine.component
My game is Fps based horror game.bt when i imported an asset package ,there is an error showing.in one of my script named FrameCounter is showing the error.It is showing that text is not a member of unityengine.component.
 var FPS:int;
 function Start () {
     Do();
 }
 function Do(){
     while(true){
         yield WaitForSeconds(1);
         GetComponent("Text").text = FPS+" : FPS";
         FPS=0;
     }
 }
 function Update () {
     FPS++;
 }
 
              Answer by cstooch · Jul 08, 2017 at 02:21 AM
Assuming this script is attached to your text object...
 GetComponent<Text>().text = FPS+" : FPS";
 
               Edit: sorry, looks like you are coding in UnityScript.. I always assume C#... might be different in UnityScript, but it looks like it should work the same.
You will also probably need to add Using statement at the top for the UI...
 using UnityEngine.UI;
 
               The using statement above might be all you need.. I don't use UnityScript, so not sure if it works the way you're doing your GetComponent, but it probably does, and just needs to know what "Text" is.
Answer by Eric5h5 · Jul 08, 2017 at 03:28 AM
Never use strings in GetComponent; that just returns a generic component, but you need to access specific components. GetComponent(Text).text 
Your answer
 
             Follow this Question
Related Questions
Convert Audio Beeps And Dashes into Text 0 Answers
GetItemByID error 0 Answers
Check if object is facing a point (ignore y axis) 1 Answer
Time.deltaTime not working? 1 Answer
how to change code editor 0 Answers