Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - maaboo

Pages: [1]
1
Support / Script for every TextMesh?
« on: January 07, 2013, 11:03:43 am »
Hi!

I'm choosing a 2D framework and 2D Toolkit looks great. I have one question at the moment: Do i really need to create a separate script for every text mesh on the scene? As i can see in the documentation ? yes, i do. It looks unconvinient (may be i'm wrong). Is it possible to insert code in another game objects? For example:

Code: [Select]
public class Player : MonoBehaviour
{

public tk2dTextMesh labelOne;
public tk2dTextMesh labelTwo;
public tk2dTextMesh labelThree;

...

}

 void Start()
    {

labelOne = GetComponent<tk2dTextMesh>();
labelTwo = GetComponent<tk2dTextMesh>();
labelThree = GetComponent<tk2dTextMesh>();

}

void Update()
    {
ShowText();
   }
   
void ShowText()
    {
labelOne.text = labelOneValue.ToString();
  labelOne.Commit();
labelTwo.text = labelTwoValue.ToString();
  labelTwo.Commit();
labelThree.text = labelThreeValue.ToString();
  labelThree.Commit();
    }

Pages: [1]