Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

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]
     
unityunity