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
0
Question by vladimirg · Aug 22, 2013 at 07:12 AM · transformpositionguitext

Transform on GUIText not working?

I'm trying to make a GUIText appear in the center of the screen. Most answers in this forum involve changing the transform. However, that doesn't seem to affect the object position at all. Technically, I can set the pixel offset to center the object on startup (using this answer), but I'd really like to make transform work. Any ideas?

EDIT:

Changing the transform to 0.5, 0.5 works in one scene, but doesn't work in others (even though they're operational). So the problem is not with the technique, but some setup detail of the scene, I just can't figure out which.

Comment
Add comment · Show 4
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 getyour411 · Aug 22, 2013 at 07:22 AM 0
Share

The transform position of X .5 and Y .5 puts it in the center of the screen, changing X to .1 moves it left, etc; that does not move it for you?

avatar image vladimirg · Aug 22, 2013 at 07:30 AM 0
Share

No - changing the transform to any value whatsoever seems to have no effect. And I double-checked the code to make sure it's not set programmatically.

avatar image getyour411 · Aug 22, 2013 at 07:38 AM 0
Share

When you press Play, what Pos does your GUItext show up at?

avatar image vladimirg · Aug 25, 2013 at 09:20 AM 0
Share

It actually doesn't. Which is most strange. EDIT: perhaps the GUILayer is turned off somehow? At least one other person reported this. But it is turned on in the scene's Inspector.

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by whydoidoit · Aug 22, 2013 at 07:33 AM

GUIText does not use world positions in the Transform at all for it's in game positioning (it wouldn't make sense in terms of GUI position). If you want text with a world position you need to use a TextMesh instead.

Comment
Add comment · Show 4 · 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 whydoidoit · Aug 22, 2013 at 07:34 AM 0
Share

Or position your GUIText's position at the result of a Camera.WorldToViewportPoint call given a world position.

avatar image getyour411 · Aug 22, 2013 at 07:36 AM 0
Share

Not sure if we might be crossing wires on this? I added a new GUIText gameobject to sample project @ Unity puts it at x.5 and y.5 and it's in the middle of the screen. Changing the X and Y moves it as one would imagine in screen terms.

avatar image whydoidoit · Aug 22, 2013 at 08:12 AM 0
Share

Yep, my fault - I'm referring to the world positions.

avatar image vladimirg · Aug 25, 2013 at 09:20 AM 0
Share

I need to center the GUIText on the viewport, not the world.

avatar image
0

Answer by robertbu · Aug 22, 2013 at 07:35 AM

GUIText lives in Viewport space. Viewport space goes from (0,0) in the lower left corner to (1,1) in the upper right corner. As @getyour411 suggests, to put the GUIText in the center of the screen using the transform, the position in the transform must be set to (0.5, 0.5). If you are using the transform to center the text, the Pixel Offset should be set to (0,0).

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 vladimirg · Aug 25, 2013 at 09:19 AM 0
Share

This works in one scene, but not others, please see my edit.

avatar image
0

Answer by BMF · Feb 12, 2014 at 04:10 PM

I just find myself struggling with GUIText too. I was trying to call this

protected GUIText displayText; displayText = transform.Find("W/Ethename").guiText;

which was returning NULL, of course. In fact, It seems you can't access it like that.


GUIText lives in Viewport space.

^This. GUIText does not have a NORMAL transform that you can access. A solution is to use the GameObject.Find() method instead.


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

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

18 People are following this question.

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

Related Questions

How to set the position of a guitext using transform? 1 Answer

Line render from an object to a click 0 Answers

Teleporting Player to a point using box colliders 1 Answer

positioning gui! 2 Answers

transform.position on basis of rotation 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