Cannot get 3D Text/Text Mesh to wrap or a attached collider used as a button to scale based on word count.

I'm using 3D Text/Text Mesh in Unity3D for dynamically loading text, but cannot get the text to wrap or a collider attached to the 3D Text/Text Mesh to scale based on growing word count.

I had the same problem. With textMesh.renderer.bounds.size I used the following method to create line breaks:

function formatText(textToFormat : String, textObj : TextMesh , desiredWithOfMesh : float) : String {
var words = textToFormat.Split(" "[0]);
var newString = "";
var testString = "";
for (var i = 0; i < words.length; i++){
testString = testString + words *+ " ";*

textObj.text = testString;
var textSize = textObj.renderer.bounds.size.x;
if(textSize > desiredWithOfMesh) {
testString = words + " ";
newString = newString + "
" + words + " ";

} else {
newString = newString + words + " ";
}
}
return newString;
}

Call the method with:
var myText = formatText(myTextString, myTextMeshObj, maxWidth)

try this it works for me make sure you add a box collider to the text mesh

var text_mesh=transform.GetComponent(TextMesh);
collider.size.x= renderer.bounds.size.x * 4;
collider.size.y= renderer.bounds.size.y * 3;
collider.center=Vector3(-1.0,0.5,0.0);