-
Notifications
You must be signed in to change notification settings - Fork 355
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
0.11 Migration: What to use instead of CalculatedSize
#701
Labels
Comments
Very good question, I am running into the same issue as well. |
This was referenced Jul 11, 2023
It is impossible to access equivalent data in 0.11 for text. You need to manually compute it. Here is how you would do it. /// Due to a regression in bevy 0.11, it is now impossible to access
/// text pre-layouting
fn create_text_measure(
fonts: Res<Assets<Font>>,
texts: Query<&Text>,
ui_scale: Res<UiScale>,
windows: Query<&Window, With<PrimaryWindow>>,
) {
let window_factor = windows.get_single().map(|w| w.resolution.scale_factor());
let window_factor = window_factor.unwrap_or(1.);
for text in &texts {
let Ok(measure) = TextPipeline::default().create_text_measure(
&fonts,
&text.sections,
ui_scale.scale * window_factor,
text.alignment,
text.linebreak_behavior,
) else {
continue;
};
measure.compute_size(/* Vec2::INFINITY if unbound */)
}
} You might be worried about the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In bevy 0.10,
CalculatedSized
used to have asize
field representing the node's "calculated" size, ie: size before layout constraints (is my understanding)This section of the migration guide describe that "CalculatedSize has been renamed to ContentSize".
However, there is no mention of what to use instead of
size
!ContentSize
has ameasure_func
field I've no idea how to get back the value that previously was there!It seems
ContentSize
was changed in bevyengine/bevy#7779, the migration guide mentionsUiImageSize
, but I also need to know the content size for text nodes.The text was updated successfully, but these errors were encountered: