Search Unity

GUIText show nothing

Discussion in '2D' started by dzaiats, Jan 31, 2015.

  1. dzaiats

    dzaiats

    Joined:
    Jan 21, 2015
    Posts:
    6
    I have empty game object. I added Component GUIText to this object. Object is initialized in the C# code on Start(). On Update() I want to set some text. But this text doesn't appear.
    DO I need to do something with this component, maybe add some additional component?

    Thanks

    Code example:


    Code (CSharp):
    1. private GUIText score;
    2.  
    3. void Start()
    4. {
    5. score = GameObject.Find("scoreText").guiText;
    6. }
    7.  
    8. void Update()
    9. {
    10. score.text = "Hello!";
    11. }
    12.  
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It needs to be positioned correctly in viewport space, but overall you'd be better off forgetting about it and using the UI system in Unity 4.6 instead.

    --Eric
     
  3. dzaiats

    dzaiats

    Joined:
    Jan 21, 2015
    Posts:
    6
    Thanks for this info. Actually I was trying to use component Text firstly. But looks like the problem is really in positioning. Because text doesn't appear even if I put some text in Component's property. The width and height of gameobject with Component text is 100x100, font size 14. I don't know what is wrong.
    Can You suggest please on what I need to pay my attention?

    Thanks