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 $$anonymous$$ · Aug 21, 2013 at 09:36 AM · resolutionscreen3dtextcorner

How can i place 3D Text to the corner of the screen?

So how can i place 3D Text to the corner of screen? I need it ,because screens have different resolutions. How can i do this? Found this script but in different resolutions it works not correct;

 public Transform objectTarget;
 public Vector3 screenPosition = new Vector3(10000,-2000,0);
 
 // Use this for initialization
 void Update () 
 {
 
    if(objectTarget != null)
    {
            objectTarget.transform.position = camera.ScreenToViewportPoint(screenPosition);
    }
 
 }


alt text

alt text

adobe photoshop image 13 - копия.jpg (158.9 kB)
adobe photoshop image 13.jpg (195.3 kB)
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

4 Replies

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

Answer by robhuhn · Aug 21, 2013 at 11:33 AM

I just made quick test where this script is attached to a TextMesh:

@edit - some improvements

 using UnityEngine;
 
 [RequireComponent(typeof(Renderer))]
 public class ScreenToWorldAlignment : MonoBehaviour 
 {
     public Vector2 screenPosition = new Vector2(0, 0);
 
     void Update () 
     {
         Vector3 tempScreenPosition = screenPosition;
         tempScreenPosition.z = -Camera.main.transform.position.z;
         
         Vector3 worldPosition = Camera.main.ScreenToWorldPoint(tempScreenPosition);
         worldPosition.x -= renderer.bounds.size.x * tempScreenPosition.x / Screen.width;
         worldPosition.y += renderer.bounds.size.y * (1 - tempScreenPosition.y / Screen.height);
         transform.position = worldPosition;
     }
 }
Comment
Add comment · Show 5 · 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 $$anonymous$$ · Aug 21, 2013 at 11:48 AM 0
Share

This works! If its not too hard for you could you make for all corners :)

avatar image robhuhn · Aug 21, 2013 at 11:55 AM 1
Share

it's dynamic and works for all positions on screen now. So Screen.width .5 and Screen.height .5 will center the text.

avatar image $$anonymous$$ · Aug 21, 2013 at 12:02 PM 0
Share

Thank you very much!

avatar image $$anonymous$$ · Aug 21, 2013 at 12:49 PM 0
Share

Could you post your previous code ,please?

avatar image robhuhn · Aug 22, 2013 at 06:20 AM 0
Share

I can't remember the previous code exactly but this one implies the previous code. What are you missing?

avatar image
0

Answer by ThomasB · Aug 21, 2013 at 10:41 AM

Not really, because the object is in 3D space. But what you could do is:

  • Move the 3D text in the scene view so it appears in the top right of the camera shot - Game View .

  • Then drag the 3D text under the Main Camera object in the hierarchy panel (so whenever the camera turns the 3D text should stay fixed in position).

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 Mikosko · Aug 21, 2013 at 12:00 PM

Create GUI camera with UI layer and add 3D Text to UI layer and set on GUI camera Culling Mask to UI layer.

Then Set on GUI camera Clear Flags to Depth only. Set Field of view, Far and Depth.

I don't try 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
avatar image
0

Answer by gordonbuyck · Apr 05, 2016 at 02:40 AM

Select the object that you would like to be placed on any of the corners of the screen (as long as object is a UI) and in the inspector panel and in the Rect Transform you should see a square picture click on that picture and set the desired position and after you click that and you press play the Object will still be where ever you left it so from their just grab it and place near to the anchor point you chose and your done.

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

instantiate object at the edge of screen 1 Answer

How to maintain high resolution custom background images for GUI elements on different screen sizes? 0 Answers

Pick sensible resolution for FullScreen Mac App 2 Answers

Screen.SetResolution doesn't work when the game starts windowed? 0 Answers

Make buttons visible in the editor? 2 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