Jump to content

GUI - Adaptive Scaling - Original width and height


Recommended Posts

When using Adaptive scaling, GUI calculates the final positioning and dimensions of controls according to idealWidth / idealHeight.

When the stage scale is adapted, the width and height of controls returns scaled values. Is there a way to retrieve the original values (before adaptive scaling is applied)?


Lately I found the need for that when setting dimensions during play - to do that I need to set the ideal values which will later be scaled by GUI.


For instance, at a certain event I need to change the children of a container and then change the width of the container to be the sum of all its children's widths.

When the stage is rendered at its ideal size there's no problem, however when it is scaled, the widths returned by the controls are scaled as well, and after setting the container's width to the already scaled sum of the childrens' widths, it is then scaled again by the GUI (as expected).


How can I access the original values before adaptive scaling is applied?


I guess I can create some util function to take into consideration current scale vs ideal, but it can make things cumbersome (especially when dealing with many such cases).

Is there by any chance a built-in solution? If not, it'd be great to have something like "original" object property in controls containing the original values like: { x, y, width, height }

Or alternatively parameters like width and height in controls can return the original values, which seems to me more practical (unless there are use cases I'm missing).

This way or another, it'd be great to be able to get and set both the original and adapted values of controls.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...