• 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 TwistedSage · Jul 02, 2012 at 10:53 PM · 2d3dconverting

Place 3D plane in 2D?

Hi everybody

I'm currently placing a 2D plane with a custom shader (circular progress bar) in front of my camera. However, I would like to place it at a 2D screen position. I tried converting screen pixel positions to 3D space but I can't get it to work.

Any help would be appreciated

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by col000r · Jul 03, 2012 at 07:46 AM

Check out Camera.ScreenToWorldPoint() - feed it a Vector3 with the desired screen position as x/y and the desired distance to the Camera as the z.

So something like this should work: transform.position = Camera.main.ScreenToWorldPoint(new Vector3(50f, 50f, 300f));

Optionally you might want to add a transform.LookAt(Camera.main.transform); so your circle faces the camera (if it's front is on the z axis, as it should be)

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
0

Answer by TwistedSage · Jul 03, 2012 at 08:12 AM

I've already tried this.

And for the life of me I can't get the %&#/! lookat script to work. The plane is just not visible. Debugging tells me that it's not pointing the right way. I attached a lookat script to the plane in question (The prefab have 2 sub planes) Also ScreenToWorldPoint does not place it in the correct place?!

Thanks for your help. Any other ideas? Is there some way I can get the plane to be drawn on top of all other geometry? (besides moving it)

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 col000r · Jul 03, 2012 at 08:29 AM 0
Share

If you want it above all other geometry at any time, use a second camera. $$anonymous$$ake a layer just for your circle and set the culling mask of the new camera to just that layer while removing that layer from the culling mask of the main camera. The new camera will now only render the circle, the main camera will render everything else. Change the depth field on the camera to deter$$anonymous$$e which one should be rendered on top.

If your plane doesn't have z looking forward, parent it to an empty gameObject, rotate it so that the plane faces forward according to the parent's orientation and apply your script to the parent ins$$anonymous$$d of the circle.

Hope this helps!

avatar image
0

Answer by TwistedSage · Jul 03, 2012 at 12:56 PM

Hi all. Thank you for your help.

I'll have a look at it :)

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to make quad's always face player? 2 Answers

Help on a 2d game. 1 Answer

GUI Follow RaycastHit 2 Answers

Close meshes render in 2D, but not 3D 0 Answers

2d mouseposition in a 3d world 3 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