Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

  • 0
Sign in to follow this  
geckoo

Move correctly an UI element

Question

Hello my dear fellas. I would like to submit you an issue with which I struggle hard today - without any good result. In my project, I use some UI elements, moving them when game is over. I create a coroutine to move UI element, but I use a Vector3 to set the destination. It works fine as expected, but when I change game resolution 16/9 for 16/10, I notice an annoying shift just with this element - a button among other texts, pictures, etc. I guess that I cannot use a Vector3 because it's a spatial 3d point and new UI uses instead anchored position. Of course, I could use an empty GO as an anchor into my canvas, but I have so many elements that I am trying to keep my project clear. Have you an idea about how I could rewrite my previous function? Thank you for your help ++

 

Please login or register to see this code.

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Is the UI element in question in 3d world space or screen space? If it's in screen space, set the anchor to the center of the screen, not the sides. The reason is when the screen size changes, the sides expand and and anchors coordinate is in a different place than it was before. A center anchor on the other hand does not change because the center of the screen never changes with the expansion of the resolution.

 

in other words, changes anchor to center and you should be good as gold

  • Thanks 1

Share this post


Link to post
Share on other sites

  • 0

Screen Space.

Ok. Thank you for your answer. I will set anchor at the middle ++

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...