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 Yoshinat0r · May 11, 2013 at 07:51 PM · guitexturefloatingrandomly

Randomly floating GUI Texture

I have an object (Object A) with a GUITexture attached to it. When I make Object A a child of Object B which is a child of my Main Camera, it causes the GUITexture of Object A to float around randomly in front of my camera when I move my mouse or just my character around the center of my map. Any help?

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Owen-Reynolds · May 11, 2013 at 10:40 PM

GUITextures can't be children of non-GUI objects (they can, but it makes the mess you're seeing.) If you want some text sticks to you "in the world" can either use a Text3D, or look up the Camera.WorldToScreenPoint trick for positioning a GUITexture.

The problem is, GUITextures use different 0-1 screen coords. If you child it to a ball, and the ball moves +1 x in the world (which is probably a small amount on the screen,) the automatic child-mover incorrectly moves the GUITexture child by +1 x screens, which pushes it completely off the edge of the 0-1 screen world.

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 Yoshinat0r · May 12, 2013 at 01:22 AM 0
Share

Why am I even seeing the GUITexture at all though? I don't have any code telling it to draw it on the screen, unless it automatically draws it every frame? That part doesn't really make sense to me. What you are saying however does make sense, I just don't understand why the game is randomly trying to draw the texture in screen space in the first place without me telling it to. I thought that the GUITexture was a sort of placeholder for a graphic that you have to manually code in when and where it is drawn.

avatar image robertbu · May 12, 2013 at 01:33 AM 0
Share

I've converted your "answer" into a question. Answers are reserved for attempts to answer your question. Putting comments as answers runs up the count of answers for a question and therefore reduces the chance for additional people will give you an answer.

As for your comment, GUITextures are very different from GUI.DrawTexture(). As @Owen Reynolds mentioned, GUITextures live in Viewport coordinates. And they don't require a code statement each from to draw. They start at (0,0) in the lower left corner, and end at (1,1) in the upper right. GUI.DrawTexture uses GUI coordinates which start in the upper right and have the same resolution as your game. And they do require that you have a code statement that draws them each frame. Both are different than world coordinates where game objects live.

avatar image Owen-Reynolds · May 12, 2013 at 02:23 AM 0
Share

If you switch to Game view (not playing, just click the Game tab,) you can see GUIText's and GUITexture's as you make them, and can visually position them on the screen.

But, if you drag next to the xy position vars, you sort of get the same oddness -- it moves them really fast since it doesn't "know" that only 0-1 are on screen.

You can use them as texture placeholders, and can dynamically move them around, if you like (many of $$anonymous$$e start offscreen at 999/999.)

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

15 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

Related Questions

How to GUI texture image change? 1 Answer

Gui Texture GameObject not showing up 1 Answer

rotating GUI texture by angle 2 Answers

Sprites and minmizing memory usage 1 Answer

How to place/add a HD image/picture in background of my game? 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