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
1
Question by AllTheGoodNamesWereTaken · Feb 12, 2021 at 04:09 AM · childrenaspect ratio

Is there a way to get Image>Preserve Aspect to work with children?

On my canvas I have an Image with Preserve Aspect ☑. Even with anchors in same location as the bounding Rect they won't scale properly in some aspects. Aspect ratio fitter attached to the children does not seem to help. Is there any way to get preserve aspect to work well with its children?

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 AbandonedCrypt · Feb 12, 2021 at 08:48 AM

I don't know if your issue really lies there and I am not sure if there are built-in ways to do this, but at last you could do something as simple as attaching a script to the parent and put this in the start method:

 for(int i = 0; i < transform.childCount; i++)
 {
     transform.GetChild(i).GetComponent<Image>()?.preserveAspect = true;
 }

(I am writing this in browser, since I am at work, so take this as pseudocode)

Comment
Add comment · Show 3 · 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 AllTheGoodNamesWereTaken · Feb 12, 2021 at 01:33 PM 0
Share

Thanks for the suggestion but it doesn't seem to work. If you have Both a parent and a child with preserveAspect to true, they still won't scale as if they are part of the same image. At least not if the image gets to wide or narrow. I'm fairly certain there isn't a built-in way to do this as preserving the aspect ratio can ignore the anchors which the child depends on (I think).

avatar image AbandonedCrypt AllTheGoodNamesWereTaken · Feb 12, 2021 at 02:11 PM 0
Share

Did you try setting the child to "Stretch" in the anchor window? Otherwise I feel like your description of what you are trying to achieve is not very clear.

avatar image AllTheGoodNamesWereTaken AbandonedCrypt · Feb 12, 2021 at 05:20 PM 0
Share

I'm trying to make is so that this alt text Doesn't become this alt text Sorry for any confusion.

1.png (15.1 kB)
2.png (7.0 kB)

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

110 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

Related Questions

How could i access to a specific collider box if it is in a children of the main Object? The script is in the main object. 1 Answer

Game Window Resolution Accurate? 1 Answer

How I can stretch texture with GUI.DrawTextureWithTexCoords ? 1 Answer

How to adapt to different aspect ratios? 1 Answer

how to build game with aspect ratio ?? 1 Answer


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