Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
1
Question by rpuls · May 14, 2019 at 08:25 AM · uicanvasscalingpositioninglayout

unity canvas, small child image of large background image should behave as if it was part of background (responsiveness)

Hello, for almost a week I have tried to achieve cutting out elements from a very large and wide image, for the intention of re-adding them as unity children of the very same image, this should look exactly as if they were still part of the large background image, no matter what screen ratio or size we are looking at. alt text The reason for this is that I want them to gain some individual properties such as clickable and eventually add movement scripting/animations to each one of them. alt text The image is a "map" of an ocean, the map is very wide (ratio 8.25). The map must be inside a canvas and at all given time bottom of the map should be fixed to the bottom of the canvas, same goes for top fixed to top. This means, that on wide screen such as mobile phones, 20% part from the left of the map should be visible, 80% parts to the right will exceed the canvas view. alt text On more squared screen you will then see even less of the maps width, but this is okay, since I want to make it scroll/drag -able horizontally. alt text Attempts: I have tried many different approaches for this to work, first attempt was inside a scroll view, where I am using vertical layout, with the following setting alt text I then set the map as the only child of the scroll view, and with these setting it is fixed top to top, bottom to bottom. I can nicely scroll it horizontally to view when is otherwise exceeding the canvas and by the explorer the entire map regardless of screen size and ratio, very nice responsiveness! alt text However, one of the elements that I cut out of the original image is a banner above the first island "infinity island" I have tried to add it as a child to the map, but no matter what settings I give it, anchor settings and with assistance of aspect ratio fitter, scale constraint, position constraint etc. Nothing seems to do the trick, no matter what i try it will either move out of position or scale, and move away from its inteded position when i resize the screen alt text

I believe this is because when I position it relative the the parent I am defining the Rect Transform position with pixels and not percentage of parent height/width. If I could say 10% to the right from the left, then no matter how I resize the canvas it should always be 10%. alt text Another way to think of a solution is to make a image exactly same dimensions as the background map image, with all pixels transparent, and then add in the banner as the only visible pixels, scaled and positioned correctly in relation to the map (like photoshop layers individually exported). alt text If I then made that image as child of the map, and gave it stretch anchor properties, it would always follow the position and scaling behavior as the background, BUT then I wont be able to make it clickable in only the banner area. alt text Another attempt have been to do it without vertical layout and without scroll view, Just use of a canvas that is screen overlay so it always matches the screen. I then put the map as child, anchor is to point left, stretch height. I then added aspect ratio fitter, with options height controls width, set the ratio as the ratio of the image, this forces it to be correct ratio and bottom to top always match canvas bottom to top. However, no matter what setting is give the banner (child) it scales wrong and gets out of position. alt text How can the desirec behavior be achieved?

Download tiny project containing these canvases: Download zip from filerdropper or from uifile.io (expires in 30 days)

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by dmarfurt · Nov 05, 2020 at 09:01 PM

@rpuls Did you end up figuring out a solution to this?

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 awsapps · Mar 31 at 07:25 PM

[Edit] Solved: Just position the anchors of the child where you want to locate them. The anchors are measured in percentage and not pixels ^^

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

250 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 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

Card array layout 1 Answer

UI Canvas position issues 0 Answers

Canvas Horizontal aligning two buttons, one bottom left and one bottom right 0 Answers

How can I scale UI text per resolution? 0 Answers

Not correct ui scaling 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