Search Unity

Example of updating text from another Object

Discussion in 'Scripting' started by hsparra, Jul 19, 2005.

  1. hsparra

    hsparra

    Joined:
    Jul 12, 2005
    Posts:
    750
    Is there an example showing the updating of some text from another object?

    Would you use FindCameObjectWithTag["myGUITextObjectsTag"] to get a handle to the text object and then set the text property like myGUITextObject.text = "The text to display"?
     
  2. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    You can either do that, or have a variable declared as a TextMesh....

    Something like this:

    Code (csharp):
    1.  
    2. var textObject : TextMesh;
    3.  
    4. function Update () {
    5.   textObject.text = "Hello World!";
    6. }
    7.  
    This will give you a variable it the inspector - just drag the Text Mesh game object over it to set it.


    [/code]