Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by POLYGAMe · Jun 21, 2012 at 12:44 PM · guitextfonthud

Odd question... can a GUIText object be displayed upside-down?

Hi guys and girls,

I was wondering if it's possible to somehow rotate a GUIText object 180 degrees on the z axis? I have tried in the inspector, but nothing works... can text be displayed in any other orientation other than the default?

I have a part of my game that makes use of an upside-down camera and I need the HUD to match and would rather not have to do everything with png files...

Cheers!

Comment
Add comment · Show 5
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 Justin Warner · Jun 21, 2012 at 12:57 PM 0
Share

Could try copy pasting from here to there: http://www.fliptext.org/ Dunno if that'd work, be funny if it did though.

avatar image tomekkie2 · Jun 21, 2012 at 01:03 PM 0
Share

Also interesting whether GUIText could be rotated by +- 90 deg. I have managed fo find the solution for rotating the texture with GUIUtility.RotateAroundPivot, possibly that would work with the text as well

avatar image POLYGAMe · Jun 21, 2012 at 01:03 PM 0
Share

LOL, I wish. I'm using custom fonts and also a lot of it is dynamic text, scores etc... so I can't just copy paste... if it were that simple, I'd use image files. Thanks, though!

avatar image POLYGAMe · Jun 21, 2012 at 01:41 PM 0
Share

Sorry, tomekkie2, that reply was for the comment above... Just saw yours now. Will try.

avatar image tomekkie2 · Jun 21, 2012 at 01:48 PM 0
Share

I have recalled and tested that again, have a look at my answer at the bottom.

2 Replies

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

Answer by CHPedersen · Jun 21, 2012 at 01:29 PM

You can accomplish that by modifying GUI.matrix. Higgy B has explained how on the forum if you follow this link:

http://forum.unity3d.com/threads/6954-video-intro?p=53105#post53105

Simply put, the GUI.matrix is an overall Translation, Rotation and Scale (TRS) which is applied globally to all GUI elements when they're being drawn. If you change it, it affects all subsequent GUI elements.

You can use it to set your rotation to 180 on the Z axis, draw your label (upside down), then set it back to its original value, then draw the rest of your GUI. It will accomplish what you're asking.

Update with code sample:

Here's how to draw only one thing with a changed GUI.matrix:

     Matrix4x4 guiMatrixOrig = GUI.matrix;
     GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 0, 180), new Vector3(1.0f, 1.0f, 1.0f)); // No translation, 180 rotation on Z, no scaling.
     // Draw something upside down now:
     GUILayout.Label("Whatever text is upside down here");
     // Reset the matrix to its original value
     GUI.matrix = guiMatrixOrig;
     GUILayout.Label("This text is normal since the matrix just got reset...");
Comment
Add comment · Show 6 · 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 CHPedersen · Jun 21, 2012 at 01:32 PM 0
Share

Edit: Sorry, I misread your post and didn't realize you were asking about a GUIText object. I'm not sure those are drawn using GUI.matrix, since they're GameObjects. In any case, the above will do what you want if you convert to using a GUI.Label ins$$anonymous$$d of a GUIText object. ;)

avatar image POLYGAMe · Jun 21, 2012 at 01:42 PM 0
Share

Ah... But it affects all GUI objects? I can't just have one upside-down and the rest default?

avatar image POLYGAMe · Jun 21, 2012 at 01:43 PM 0
Share

Oh, wait... I could use labels for some (upside down) and guitext for others. Thanks!

avatar image CHPedersen · Jun 22, 2012 at 09:52 AM 1
Share

No, don't do that. :) You don't need GUIText objects for some things and GUI.Labels for others. Like a lot of other things in Unity, modifying the GUI.matrix works like a state machine. Everything drawn BEFORE you change it is normal, everything drawn AFTER you change it gets affected. When you don't want things to get drawn upside down anymore, you just change it back. Read my answer again. That is what I meant by "then set it back to its original value, then draw the rest of your GUI". Doing so ensures that the rest of your GUI gets drawn with the original (not upside down) GUI.matrix.

avatar image CHPedersen · Jun 22, 2012 at 09:56 AM 1
Share

Also note that GUIText objects are likely only there for backwards compatibility reasons. They were the first GUI-stuff Unity Tech created. The GUI system was introduced later and is meant to supercede the GameObject versions of GUI elements.

I've added a code snippet that demonstrates how to draw only one thing with a changed GUI.matrix.

Show more comments
avatar image
2

Answer by tomekkie2 · Jun 21, 2012 at 01:45 PM

Here is the code to put in the OnGUI function to do that:

 var matrixBackup:Matrix4x4  = GUI.matrix;
 var thisAngle:float = 180;
 var pos:Vector2 = Vector2(Screen.width/2, Screen.height/2);
         
 GUIUtility.RotateAroundPivot(thisAngle, pos);
         
 //all to be rotated put here
 GUI.Label(new Rect(Screen.width/2-100, Screen.height/2-50,200,50), "Upside down");  
 //end of rotated
     
 GUI.matrix = matrixBackup;

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 POLYGAMe · Jun 21, 2012 at 01:49 PM 0
Share

Cheers :-)

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

Changing a GUILabel text SIZE 3 Answers

Why aren't asian fonts rendering dynamically? 0 Answers

Problem with GuiFont - Not appearing 0 Answers

Color.white not so much white... 3 Answers

Alpha not working in GUITex 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