Iīm having trouble understanding how I can batch some textMesh objects. I have looked at the code example
http://www.unikronsoftware.com/2dtoolkit/docs/2.00/advanced/scripting_static_sprite_batcher.html but I canīt seem to figure out how i can apply that to my current code.
For demo purposes this is what I got.
public GameObject go;
public GameObject prefab;
private tk2dStaticSpriteBatcher batcher;
void Start ()
{
batcher = go.AddComponent<tk2dStaticSpriteBatcher>();
GameObject item;
for(int i = 0; i < 100; i++)
{
Vector3 p0 = new Vector3(UnityEngine.Random.Range(-10,10), UnityEngine.Random.Range(-10,10), UnityEngine.Random.Range(-10,10));
item = Instantiate(prefab, p0, Quaternion.identity) as GameObject;
item.transform.parent = go.transform;
int num = UnityEngine.Random.Range(0,26);
char letter = (char)('a' + num);
var textMesh = item.GetComponent<tk2dTextMesh>();
textMesh.text = letter.ToString();
textMesh.Commit();
}
}
At this point I can hit the "Commit" button on the Sprite Batcher script and the objects get baked into one mesh.
How can I do the Commit dynamically?
Thanks.
Petur