Author Topic: Can you have sprites that respect the minimum area while maintaining aspect rati  (Read 6613 times)

greyhoundgames

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 39
    • View Profile
Consider a common case of a box with a stat icon in it. If you set the stat icon to be anchored to the box, and give it a basedOnWidth\height aspect ratio, as the box grows in a single dimension, the icon will either ignore it(ok, or grow with it spilling over the side in the other dimension). Is there a way to have something like size based on minimum of both width and height. Or an ability to put a sprite on free aspect ratio but then making the actual render be aspect ratio dependant still?

See the example for boxes with icons in them. The icons are set to based on width aspect ratio. As the box gets wider, the icons spill over the top.
Desired would be for them to respect both the width and height without getting distorted.


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Nothing built-in, no. You'd need a script that picks the lowest of the two and resizes the sprite accordingly (or changes the anchors / aspect ratio source).

greyhoundgames

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 39
    • View Profile
Ok thanks. I just wanted to say I appreciate how you are on here every day answering questions.

r.pedra

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 20
  • Posts: 131
    • View Profile
I know that UIStretch is deprecated but it's possible with it no? With FillKeepingRatio or FillInternalKeepingRatio it should work no?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Hmm... maybe. I haven't thought of that deprecated script in a while...