diff --git a/crates/bevy_ui/src/layout/mod.rs b/crates/bevy_ui/src/layout/mod.rs index 886cef8b9cb4a..623208f11711f 100644 --- a/crates/bevy_ui/src/layout/mod.rs +++ b/crates/bevy_ui/src/layout/mod.rs @@ -1,6 +1,3 @@ -use bevy_text::TextPipeline; -use thiserror::Error; - use crate::{ContentSize, DefaultUiCamera, Node, Outline, Style, TargetCamera, UiScale}; use bevy_ecs::{ change_detection::{DetectChanges, DetectChangesMut}, @@ -14,10 +11,13 @@ use bevy_ecs::{ use bevy_hierarchy::{Children, Parent}; use bevy_math::{UVec2, Vec2}; use bevy_render::camera::{Camera, NormalizedRenderTarget}; +#[cfg(feature = "bevy_text")] +use bevy_text::TextPipeline; use bevy_transform::components::Transform; use bevy_utils::tracing::warn; use bevy_utils::{HashMap, HashSet}; use bevy_window::{PrimaryWindow, Window, WindowScaleFactorChanged}; +use thiserror::Error; use ui_surface::UiSurface; mod convert; diff --git a/crates/bevy_ui/src/layout/ui_surface.rs b/crates/bevy_ui/src/layout/ui_surface.rs index 75b4428af0f9e..f191042aa3c13 100644 --- a/crates/bevy_ui/src/layout/ui_surface.rs +++ b/crates/bevy_ui/src/layout/ui_surface.rs @@ -231,6 +231,8 @@ without UI components as a child of an entity with UI components, results may be available_height: available_space.height, #[cfg(feature = "bevy_text")] font_system, + #[cfg(not(feature = "bevy_text"))] + font_system: std::marker::PhantomData, }, style, ); diff --git a/crates/bevy_ui/src/measurement.rs b/crates/bevy_ui/src/measurement.rs index 1d4d7beb8021c..5c565930f53d0 100644 --- a/crates/bevy_ui/src/measurement.rs +++ b/crates/bevy_ui/src/measurement.rs @@ -23,6 +23,9 @@ pub struct MeasureArgs<'a> { pub available_height: AvailableSpace, #[cfg(feature = "bevy_text")] pub font_system: &'a mut bevy_text::cosmic_text::FontSystem, + // When `bevy_text` is disabled, use `PhantomData` in order to keep lifetime in type signature. + #[cfg(not(feature = "bevy_text"))] + pub font_system: std::marker::PhantomData<&'a mut ()>, } /// A `Measure` is used to compute the size of a ui node diff --git a/crates/bevy_ui/src/node_bundles.rs b/crates/bevy_ui/src/node_bundles.rs index 0610fee35a967..95fa9990b464f 100644 --- a/crates/bevy_ui/src/node_bundles.rs +++ b/crates/bevy_ui/src/node_bundles.rs @@ -10,6 +10,7 @@ use crate::{ UiImage, UiMaterial, ZIndex, }; use bevy_asset::Handle; +#[cfg(feature = "bevy_text")] use bevy_color::Color; use bevy_ecs::bundle::Bundle; use bevy_render::view::{InheritedVisibility, ViewVisibility, Visibility};