Author Topic: UIStretch inside of an anchored UIWidget OR FitInternalKeepingRatio with 3.0.7  (Read 4057 times)

raydenuni

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 18
    • View Profile
I have a sprite I would like to fit in a section of the screen. Let's say the middle 3/5 at the bottom. I built the following to do so:

- Container - UIWidget with a Unified anchor of (custom 0.2, custom 0.8, bottom 0, top 0)
-- Sprite - UIStretch with FitInternalKeepingRatio and then appropriate InitialSize values for my sprite

In the editor, this will properly scale up the image, maintaining aspect ratio, to fit in the bottom of the screen. But in-game, it is pushed off screen I believe.

Potential bug somewhere in how UIStretch and Anchors interact?

----

Alternatively, how to implement FitInternalKeepingRatio using the new 3.0.7 anchors? This post seems to be asking the same question: http://www.tasharen.com/forum/index.php?topic=7092.msg33441#msg33441

If there's a better way to do this, I'm all ears.

raydenuni

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 18
    • View Profile
It seems that if I make a sprite underneath UIRoot and give it a unified anchor on UIRoot, it is not visible.

Something about calculating the Y position is failing. I even updated to 3.0.8 to try and use the new widget keep aspect ratio to simplify it and I'm still running into the same issue. Even creating a new window, putting one sprite and setting an anchor doesn't seem to work.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
UIStretch is a legacy script. You shouldn't be using it with the new anchoring system.

If you want to have some sprite keep a specific aspect ratio, then change that sprite to actually have an aspect ratio. It's "Free" by default, meaning it uses width/height.

raydenuni

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 18
    • View Profile
I saw that, but I was on 3.0.7 and didn't have the new sprite aspect ratio field. It's much simpler with the new way, but I'm still running into the issue where the image draws in the wrong location, even when I'm not using UIStretch.

raydenuni

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 18
    • View Profile
Also the strange part of it is that the widget is drawn correctly in the editor, but not when I run the scene.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Change the pivot point to something like top-left, then anchor on 3 of the 4 sides (for example left, top, right).