system
1
Hey everyone,
Try as I may, I just can’t seem to find an answer to the following question - is there a way to display text vertically instead of horizontally (from within the GUI or OnGUI settings)?
Example:
“Hello World”
"
H
e
l
l
o
"
I’m trying to set up a screen of text in Japanese and I need it to display vertically (running from right to left) is possible.
Any ideas?
Eric5h5
3
You’d make a function for doing so. As a quick example,
function OnGUI () {
GUILayout.Label(VerticalText("Hello"));
}
function VerticalText (input : String) : String {
var sb = new System.Text.StringBuilder(input.Length*2);
for (var i = 0; i < input.Length; i++) {
sb.Append(input*).Append("
");*
- }*
- return sb.ToString();*
}
Ideally you’d want to preprocess the text, rather than converting it over and over like that every frame.
Rennat
2
I don’t know of a built in way to do this but I would loop over the input string as an array and make smaller arrays for each column (you can pick an arbitrary row count for a column or do some math with the screen height and font size) then set up your GUI as follows
GUILayout.BeginHorizontal()
// loop over columns with
GUILayout.BeginVertical()
// loop over characters in a column with
GUILayout.Label()
GUILayout.EndVertical()
GUILayout.EndHorizontal()
Probably not the most efficient way of doing this but it’s what I can think of off the top of my head.
If you instead want to rotate the whole thing (characters included) check out GUI.matrix which is lacking thorough documentation but a good example can be found in this post by Hanford Lemoore
system
4
I ultimately converted a word file into a texture and applied it to a plane. Was an awkward, time-consuming process but it got the job done. The scripts above were both informative and creative, but didn’t mesh well with the Japanese language. Thanks for the suggestions!
There is a better method.
Straight out of C# referrence - what they do is they use GUI.matrix to rotate the text on its side. it’s an elegant solution which provides least amount of headache.