2D Toolkit Forum
2D Toolkit => Support => Topic started by: rajmehta2509 on February 16, 2015, 01:23:43 pm
-
I have been trying to make text notification in which i am using 2dtoolkit text and 2dtoolkit tiled sprite as background the problem is i need to scale my background according to the dimensions of the text but i could not find a way to calculate the height and width of the text.
-
I'm using
myTk2dTextMesh.renderer.bounds.size.x // for width
myTk2dTextMesh.renderer.bounds.size.y // for height
Also can use
myTk2dTextMesh.GetMeshDimensionsForString(theString) // returns a Vector2 with dimensions
-
renderer.bounds.size returns the value in world space. you can convert that into pixels through the Camera.WorldToScreenPoint function but you probably don't need to do that - you can work out the buonds of the sprite and then scale it appropriately.
-
That works like a charm thanks