Skip to content

Apply autosize continuously instead of relying on transforms #6566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

minetoblend
Copy link

Follow-up/alternative to #6560 to explore another approach which applies the AutoSize animation continuously instead of relying on transforms.

I tried keeping the AutoSizeDuration property (partially because FlowContainer.LayoutDirection uses it) but the actual duration will only roughly match the specified amount now given that the actual time taken depends on how big the change was.
Perhaps exposing this as a parameter with a more explicit name (i.e. AutoSizeDamping/Decay) would be a better choice here.

@minetoblend minetoblend changed the title Feature/continuous autosize Make autosize be applied continuously instead of relying on transforms Apr 11, 2025
@minetoblend minetoblend changed the title Make autosize be applied continuously instead of relying on transforms Apply autosize continuously instead of relying on transforms Apr 11, 2025
return;
}

Vector2 newSize = Interpolation.DampContinuously(baseSize, targetSize, duration / 4, Time.Elapsed);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The duration / 4 value is kind of eyeballed here, it will bring the current value within 0.4% of the target value after the given duration has passed. When testing this the resulting animation roughly landed in the right ballpark for most cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant