Author Topic: Resizing a game during gameplay.  (Read 3032 times)

roberto_sc

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Resizing a game during gameplay.
« on: February 03, 2014, 12:43:00 AM »
I'm working on porting a game that was originally made to work in some resolutions, but now I have to support resizing (hence changing aspect ratio) during gameplay.

GUI elements are anchored so everything looks good when you start the game at a specific resolution. Also, UIRoot is set to FixedSize.

For supporting resizing I made a generic script that changes the Manual Height of the UIRoot proportionally with the new aspect ratio. So for example, when the window is rescaled to a narrower aspect ratio, the gui elements would be scaled to a smaller size to fit the width (imagine a horizontal toolbar of buttons that need to fit the width).

The problem with this solution is that some elements have a delta in their Y position to be properly positioned beneath another element, and changing the Manual Height of the UIRoot won't change this delta, so I end up with elements in wrong position or under other elements.

Is there a way to "reload" these elements, so their position and size can be recalculated based on the new aspect ratio?


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Resizing a game during gameplay.
« Reply #1 on: February 04, 2014, 02:11:21 AM »
Are you using the new anchor system or the old one? Old one generally has anchors run only once by default.

roberto_sc

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: Resizing a game during gameplay.
« Reply #2 on: February 04, 2014, 02:59:02 PM »
I'm using the old one.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Resizing a game during gameplay.
« Reply #3 on: February 05, 2014, 04:37:46 PM »
Then uncheck the "run only once" option.