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 amukhi · Apr 09, 2015 at 04:28 AM · c#imagewords

How to get a image in the top right corner

I am new to unity and I was wondering how would I get a image to always stay in the top right corner, no matter what the screen size. Also would it be possible to place the text "x3" to the right of the image?

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 Wolfbane54 · Apr 09, 2015 at 11:40 AM

Not sure if this will help, but take a look at this and see what you think.

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
Wiki

Answer by NDPW · Apr 09, 2015 at 12:50 PM

This should work for an object (transform) in 2d, I didn't test it so you might need to change some stuff.

yourobject.position = new Vector2 (MCam.ScreenToWorldPoint (new Vector3 (Screen.width, 0f, 0f)).x + 0f, 3.5f);

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 DiegoSLTS · Apr 09, 2015 at 01:16 PM

Are you trying to make some HUD? For a HUD or other 2D GUI Unity has a whole new system to make things easier.

You have the legacy GUI system, where you need to handle everything with code, and you have the new uGUI system, where you place objects in the hierarchy just like any other object.

Using the uGUI you have to add an Image to your hierarchy (Create -> UI -> Image). This will add a Canvas with the Image inside, and an EventSystem.

The Canvas has a CanvasScaler component that handles how all the UI is resized (or not). To always fit the screen use the UI Scale Mode "Scale with screen size", and in the Screen Match mode select Expand. This setup will make sure your canvas always fits inside your screen.

Now, the UI Image (or any UI component) can be anchored to different parts of the screen or their parent objects. For your question the Image should have it's pivot set to the top-right corner, the anchor to top-right too, and make sure posX and posY are set to 0.

This will place the Image at the top right, but your next question was to add a "x3" at the right, so you'll have to make something different.

You can create an empty game object inside the canvas and place that game object in the top-right corner. Then inside that object you can add the UI Image and a UI Text.

Look here to understand how the new UI works: https://unity3d.com/es/learn/tutorials/modules/beginner/ui/ui-canvas

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Trying to place an UI Canvas Image next to another UI Image 1 Answer

Changing RawImage position killing frame rate on Android 1 Answer

Qos type ReliableFragmented channel, won't fragment our stream 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