I need to know how to get a string's length in pixels in C# Unity3D.
string msg = ""You Must be from South Carolina!";
How do I get the above message string length in Pixels?.
I need to know how to get a string's length in pixels in C# Unity3D.
string msg = ""You Must be from South Carolina!";
How do I get the above message string length in Pixels?.
Here is a way you can get the width of your String. Nb: You should know what font you use :
string msg = "You Must be from South Carolina!";
Font stringFont = new Font("Arial", 12);
using (Bitmap tempImage = new Bitmap(400,400))
{
SizeF stringSize = Graphics.FromImage(tempImage).MeasureString(msg , stringFont);
double width = stringSize.Width;
}