Calculate the desired length of the text control in Ugui in unity

Source: Internet
Author: User

The background is that I need to be in unity when I press a key and then show the information of the object that was hit by the Ray. The information of the object has been sorted into txt text before. Read it for a moment. Then there is a problem, because each object's introductory information is not the same length, then if the text within the text control is longer than the length of the display, more than the part will not be displayed. So what's the deal?

I was to facilitate the TXT text in all the text and symbols, and then all the newline character is the/n number of records, and then calculate the corresponding font size line has a few words, such as my 18th font, then one line can write 30 words, and then calculate the txt text in the number of words.

Then the length of the text box required = (number of total text/line of text + newline) * Length of line. Just like my total number of words is 2100, a line of 30 words, 19 newline characters, the length of a line is 16. The result is 1424 lengths.

Calculate the desired length of the text control in Ugui in unity

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.