Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

GUIText not visible?

Discussion in 'Scripting' started by spadin, Aug 31, 2007.

  1. spadin

    spadin

    Joined:
    Aug 13, 2007
    Posts:
    26
    Hi,

    I have a script that's loading a new level. There is an object with many children that is kept alive through a DontDestroyOnLoad call. This has variables such as score, timer, etc.. that should be kept throught the different levels.

    I have one object which has a GUIText component. Upon opening the new level I want to show the score, health, timer, etc. on the screen in the GUIText. Now this all works well inside the editor, but when I do a web build, the text never shows up. I know the text is being set, because I can see that in the console log. I also, know the GUIText object survives the level load because I'm logging it's existence and it exists. I also know the the GUIText is enabled. I even tried setting the color of the GUIText just to make sure, but nothing seems to work.

    Any suggestions?

    Thanks,
    Sandro
     
  2. spadin

    spadin

    Joined:
    Aug 13, 2007
    Posts:
    26
    I figured it out. I set a tag to the object that has the GUIText. I'm thinking the correct GUIText was not being found when I was using the FindObjectOfType().

    On a seperate note, is the use of tags any better/worse, performance-wise?

    Thanks,
    Sandro
     
  3. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    All functions that have to search for something are slow. If you have code that uses them in Update(), FixedUpdate() or in tight loops, try and move the search function to Start() and cache the reference you get from it.