Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by BlacKatFever · Sep 01, 2011 at 06:45 AM · textvertical

Vertical Text

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?

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Rennat · Sep 01, 2011 at 07:03 AM 0
Share

Do you want it the letters to be horizontal but words vertical or do you want to rotate the word so the whole thing is vertical?

avatar image BlacKatFever · Sep 01, 2011 at 07:12 AM 1
Share

I'd like the letters to remain horizontal but the words / sentences to be aligned vertically. $$anonymous$$ind of like the hotel sign in this picture here. → http://bit.ly/qF4Gb5

avatar image Rennat · Sep 01, 2011 at 07:16 AM 0
Share
  • for clarifying with a visual :)

4 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by BlacKatFever · Oct 05, 2011 at 09:33 AM

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!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
3

Answer by Eric5h5 · Sep 01, 2011 at 10:13 AM

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[i]).Append("\n");
     }
     return sb.ToString();
 }

Ideally you'd want to preprocess the text, rather than converting it over and over like that every frame.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by Rennat · Sep 01, 2011 at 07:15 AM

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

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Rennat · Sep 01, 2011 at 07:18 AM 0
Share

Just realized I'm not sure how GUILayout.Label will react to just a space between words, you may have to use a conditional and use GUILayout.Space when you run across a space character

avatar image BlacKatFever · Sep 01, 2011 at 07:22 AM 0
Share

I'll give this a try, but with the sheer amount of text that we'll be using (it's basically a novel / game-type of project), I'm not sure that will be a feasible method outside of the bite-sized prototype we're making.

Seems like my other alternative is to do the whole thing up in some word processing program, convert it to an image file and then stick it on an in-game object. sigh

Thanks for the input, though, will definitely give it a try.

Going to leave this thread open a little while longer to see if there any other suggestions. :D

avatar image Rennat · Sep 01, 2011 at 07:29 AM 0
Share

Yea it's probably not the best way to do it but it should work in a scroll area and you can always abstract the logic into a function that just takes the input string and makes all the GUILayout calls. Then just call the function in OnGUI where you need it.

Definitely keep looking for a better way of doing it and update us when you find it to help the next person that runs into it.

avatar image
0

Answer by smoketh · May 13, 2020 at 07:14 AM

There is a better method.

https://github.com/Unity-Technologies/UnityCsReference/blob/3c2fbfebd60cd91d91c82a8b32ae26281687544d/Editor/Mono/Inspector/PhysicsManagerInspector.cs#L40 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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Siccity · May 13, 2020 at 07:21 AM 0
Share

Not only is GUI.matrix a headache in itself, it also will not produce the result OP asked for.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

ScrollRect.verticalNormalizedPosition disables scrolling capability. 1 Answer

vertical scrolling, non editable text area. 1 Answer

Writing text to UI Text new line 1 Answer

DIALOGUE BRANCH CREATION? 1 Answer

How to display images on top of TileMap during runtime? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges