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 Brooke_Godbold · Jul 01, 2020 at 08:03 PM · resolutionuser interface

UI Position of Images changing at different resolutions

I've recently been playing around with different resolutions in my game, and noticed that most of the UI elements had the wrong positions and sizes at different resolutions. I fixed most of these issues by either setting the anchor points on the elements, or by setting the worldPositionStays to false when Parenting the element.

However, there is one part of my UI which is still playing up. I have a set of 'Cinematic Bars' which are designed to lower, be set to a position, or rise when the methods are called.

How I set them up is (depending on whether they need to lower into the scene or simply be in a lowered position on start), I Instantiate two objects from the Prefab, set their Anchored Positions to where needed, and then Parent them to an empty RectTransform 'Container' object, with worldStaysPosition set to false as with everything else. I'm setting the initial positions based on relative Screen sizes (which has been a hack in of itself because the positioning here seems to be all over the shop at Runtime). It works at my target resolution of 1920px, but at anything else, like 1024px, the lower bar appears halfway up the screen rather than the bottom. Does anyone have any insight over how I should be doing this?

 public void SetBarsToLowered()
 {
     cinematicComplete = false;
     InstantiateCinematicBars(0f, Screen.height * 0.8f * -1);
 }
 
 public void LowerBars()
 {
     cinematicComplete = false;
     InstantiateCinematicBars(Screen.height * 0.2f, Screen.height * 1.2f * -1);
 
     StartCoroutine(DoLowerCinematicBars());
 }
 
 private void InstantiateBars(float topYPos, float bottomYPos)
 {
     cinematicTopBar = Instantiate(cinematicsBarPrefab, cinematicContainer.transform);
     cinematicTopBar.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, topYPos);
     cinematicTopBar.transform.SetParent(cinematicContainer.transform, false);
 
     cinematicBottomBar = Instantiate(cinematicsBarPrefab, cinematicContainer.transform);
     cinematicBottomBar.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, bottomYPos);
     cinematicBottomBar.transform.SetParent(cinematicContainer.transform, false);
 }
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
0

Answer by HappyPixel27 · Jul 02, 2020 at 02:15 AM

Im not that skilled with this but i think that you need to anchor your empty object as well.

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 Brooke_Godbold · Jul 02, 2020 at 10:32 AM 0
Share

I did think of that, but I added a RectTransform with the anchors set, and it hasn't made a difference.

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

133 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 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Is there a way to keep camera and UI always the same? 1 Answer

Weird graphic glitch on certain Android devices (2019.2.8f1) 0 Answers

Changing Aspect Ration on Different Resolutions 1 Answer

How to scale according to different mobile resolutions? 0 Answers

Multi resolution GUI From 1920x1080 source to all lower resolutions (canvas scaler dead end) 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