- Home /
 
               Question by 
               garrymcgee · Nov 20, 2014 at 06:55 AM · 
                javascriptguitextguitext  
              
 
              What's wrong with my function? It keeps telling me 'loseText' is not a member of 'UnityEngine.GUIText'. Please help, please and thank you!
function HitEnemy(enemy : Collider): IEnumerator {
 if(powerMode == false)
 {
     
     
     lives --;
     
     livesText.text = "Lives: " + lives;
     
     
     if(lives <= 0)
     {
     
         
         **GUIText.loseText.enabled = true;** 
                 
         Destroy(gameObject);
     }
     else
     {
         collider.enabled = false;
         
         
         
         renderer.enabled = false;
         yield WaitForSeconds(2);        
         
         
         collider.enabled = true;
         
         
         renderer.enabled = true;
         
         
     }
 }
 else
 {
     
     AddScore(enemyValue, false);
     enemy.SendMessage("Eat");
 }
}
               Comment
              
 
               
              This line:
 GUIText.loseText.enabled = true;
is wrong, loseText is not a default member of the GUIText class, so the error is 100% correct.
the enabled member is:
 GUIText.enabled = true;
But this doesn't seem to follow any normal UI logic as it is not a reference to anything, so...
You would explain what you're trying to do, what objects exist in the scene you're trying to interact with, etc.
Your answer
 
 
             Follow this Question
Related Questions
Setting Scroll View Width GUILayout 1 Answer
Limit on GUI Components? 0 Answers
changing font + size of text 1 Answer
HELP with scripting where GUI is involved 2 Answers
Create GUIText from Javascript 3 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                