Skip to content

Commit 3082ddb

Browse files
committed
Explain why we aren't unwrapping for bevy_sprite cases.
1 parent 720db5b commit 3082ddb

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

crates/bevy_sprite/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ impl Plugin for SpritePlugin {
110110
#[cfg(feature = "bevy_sprite_picking_backend")]
111111
app.add_plugins(SpritePickingPlugin);
112112

113+
// We intentionally aren't unwrapping the render app since this plugin may be added in
114+
// headless situations (e.g., to spawn a scene that includes a Sprite).
113115
if let Some(render_app) = app.get_sub_app_mut(RenderApp) {
114116
render_app
115117
.init_resource::<ImageBindGroups>()
@@ -142,6 +144,7 @@ impl Plugin for SpritePlugin {
142144
}
143145

144146
fn finish(&self, app: &mut App) {
147+
// We intentionally aren't unwrapping the render app. See `build()` for details.
145148
if let Some(render_app) = app.get_sub_app_mut(RenderApp) {
146149
render_app
147150
.init_resource::<SpriteBatches>()

crates/bevy_sprite/src/mesh2d/mesh.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ impl Plugin for Mesh2dRenderPlugin {
6868

6969
embedded_asset!(app, "mesh2d.wgsl");
7070

71+
// We intentionally aren't unwrapping the render app since this plugin is added
72+
// unconditionally by `SpritePlugin`, which may itself be added in headless situations.
7173
if let Some(render_app) = app.get_sub_app_mut(RenderApp) {
7274
render_app
7375
.init_resource::<ViewKeyCache>()

0 commit comments

Comments
 (0)