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 - peturg

Pages: [1]
1
Support / Re: Help with dynamic TextMesh batching
« on: August 26, 2013, 07:12:30 pm »
I looked into the tk2dStaticSpriteBatcherEditor class. I was able to fish out what I needed.
But I appreciate the warning.

2
Support / Re: Help with dynamic TextMesh batching
« on: August 26, 2013, 04:48:15 pm »
Thank you for the quick reply.

The thing is I actually have a few thousand TextMeshes in different "container" GameObjects. The drawCalls is around 80 now. I just noticed that when I added the spriteBatcher to few of the containers and hit Commit the drawCalls dropped. So I was interested in trying it.

Each textMesh has a random text, scale, alpha, position and rotation.

Any help would be appreciated.
Petur

3
Support / Help with dynamic TextMesh batching
« on: August 26, 2013, 04:14:05 pm »
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.
Code: [Select]
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

4
Support / Re: Setting Color to Text Mesh after modifying its vertices
« on: October 03, 2012, 01:14:45 pm »
Thanks for quick reply. It works.

5
Support / Setting Color to Text Mesh after modifying its vertices
« on: October 03, 2012, 12:53:03 pm »
After changing vertices in Text Mesh I?m not able to set a new Color to it.

Am I missing something ?

Example:
Code: [Select]
GameObject item = Instantiate(prefab, transform.position, transform.rotation) as GameObject;
var textMesh = item.GetComponent<tk2dTextMesh>();
string text = "Hello 2D Toolkit";
textMesh.maxChars=text.Length;
textMesh.text = text;
Color c = textMesh.color;
c = Color.red;
textMesh.color = c;
textMesh.Commit();

MeshFilter mf = textMesh.GetComponent<MeshFilter>();
int n;
Vector3[] vertices = mf.mesh.vertices;
for(int k=0; k<text.Length; k++)
{
n = Random.Range(-3,3);

for(int j=0; j < 4; j++)
{
vertices[k*4 + j].z += n;
}
}

mf.mesh.vertices = vertices;
mf.mesh.RecalculateBounds();

Color c1 = textMesh.color;
c1 = Color.blue;
textMesh.color = c1;
textMesh.Commit();

6
Support / Re: Text Mesh loop through each character
« on: October 02, 2012, 06:22:26 pm »
Thank you, that guided me in the right direction.

If anyone is interested in this.
Code: [Select]
GameObject item = Instantiate(prefab, transform.position, transform.rotation) as GameObject;
var textMesh = item.GetComponent<tk2dTextMesh>();
string text = "Hello 2D Toolkit";
textMesh.maxChars=text.Length;
textMesh.text = text;
textMesh.Commit();

MeshFilter mf = textMesh.GetComponent<MeshFilter>();
int n;
Vector3[] vertices = mf.mesh.vertices;
for(int k=0; k<text.Length; k++)
{
n = Random.Range(-3,3);

for(int j=0; j < 4; j++)
{
vertices[k*4 + j].z += n;
}
}

mf.mesh.vertices = vertices;
mf.mesh.RecalculateBounds();

7
Support / Re: Text Mesh loop through each character
« on: October 02, 2012, 04:54:41 pm »
Yes, that would be helpful.
Thanks

8
Support / Re: Text Mesh loop through each character
« on: October 02, 2012, 04:46:45 pm »
Yes I would like to change the position and possibly the scale of individual char in a text mesh.
The idea was to animate each char to a different Z position and at some point back to the original position.

9
Support / Text Mesh loop through each character
« on: October 02, 2012, 03:04:08 pm »
Hi, how can I loop through all the characters in a text mesh and change their position e.g?

So this is basically what I got.
Code: [Select]
GameObject item = Instantiate(prefab, transform.position, transform.rotation) as GameObject;
var textMesh = item.GetComponent<tk2dTextMesh>();
string text = "Hello 2D Toolkit";
textMesh.maxChars=text.Length;
textMesh.text = text;
textMesh.Commit();

Any input appreciated.
Petur


Pages: [1]