Created
January 18, 2021 03:19
-
-
Save kyubuns/8658fa4c601c620928a3a9063a915de8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fontAsset = AssetDatabase.LoadAssetAtPath<Font>(fontPath); | |
var settings = new TextGenerationSettings | |
{ | |
generationExtents = Vector2.zero, | |
textAnchor = TextAnchor.MiddleCenter, | |
alignByGeometry = false, | |
scaleFactor = 1.0f, | |
color = Color.white, | |
font = fontAsset, | |
fontSize = Mathf.RoundToInt(fontSize), | |
pivot = Vector2.zero, | |
richText = false, | |
lineSpacing = 0, | |
fontStyle = FontStyle.Normal, | |
resizeTextForBestFit = false, | |
updateBounds = false, | |
horizontalOverflow = HorizontalWrapMode.Overflow, | |
verticalOverflow = VerticalWrapMode.Overflow | |
}; | |
var textGenerator = new TextGenerator(); | |
var width = textGenerator.GetPreferredWidth(rawText, settings); | |
var height = textGenerator.GetPreferredHeight(rawText, settings); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment