Skip to content

Commit

Permalink
Add bevy_editor_core crate (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-blackbird authored Dec 2, 2024
1 parent 6643659 commit 9348e31
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ bevy_toolbar = { path = "bevy_widgets/bevy_toolbar" }
bevy_tooltips = { path = "bevy_widgets/bevy_tooltips" }

# general crates
bevy_editor_core = { path = "crates/bevy_editor_core" }
bevy_asset_preview = { path = "crates/bevy_asset_preview" }
bevy_editor = { path = "crates/bevy_editor" }
bevy_editor_camera = { path = "crates/bevy_editor_camera" }
Expand Down
1 change: 1 addition & 0 deletions bevy_editor_panes/bevy_scene_tree/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edition = "2021"

[dependencies]
bevy.workspace = true
bevy_editor_core.workspace = true
bevy_pane_layout.workspace = true
bevy_i-cant-believe-its-not-bsn.workspace = true

Expand Down
9 changes: 2 additions & 7 deletions bevy_editor_panes/bevy_scene_tree/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use bevy::{
picking::focus::PickingInteraction,
prelude::*,
};
use bevy_editor_core::SelectedEntity;
use bevy_i_cant_believe_its_not_bsn::WithChild;
use bevy_pane_layout::prelude::{PaneAppExt, PaneStructure};
use std::ops::Deref;
Expand All @@ -22,7 +23,7 @@ impl Plugin for SceneTreePlugin {
fn build(&self, app: &mut App) {
app.register_pane("Scene Tree", setup_pane);

app.init_resource::<SelectedEntity>().add_systems(
app.add_systems(
PostUpdate,
(
reset_selected_entity_if_entity_despawned,
Expand Down Expand Up @@ -56,12 +57,6 @@ fn setup_pane(pane: In<PaneStructure>, mut commands: Commands) {
);
}

/// The currently selected entity in the scene.
// TODO: Move to a different crate so that it can be controlled by things like mesh picking
// and accessed by the inspector without depending on this crate.
#[derive(Resource, Default)]
pub struct SelectedEntity(Option<Entity>);

fn reset_selected_entity_if_entity_despawned(
mut selected_entity: ResMut<SelectedEntity>,
entities: &Entities,
Expand Down
10 changes: 10 additions & 0 deletions crates/bevy_editor_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "bevy_editor_core"
version = "0.1.0"
edition = "2021"

[dependencies]
bevy.workspace = true

[lints]
workspace = true
18 changes: 18 additions & 0 deletions crates/bevy_editor_core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//! This crate provides core functionality for the Bevy Engine Editor.
use bevy::prelude::*;

/// Plugin for the editor scene tree pane.
pub struct EditorCorePlugin;

impl Plugin for EditorCorePlugin {
fn build(&self, app: &mut App) {
app.init_resource::<SelectedEntity>()
.register_type::<SelectedEntity>();
}
}

/// The currently selected entity in the scene.
#[derive(Resource, Default, Reflect)]
#[reflect(Resource, Default)]
pub struct SelectedEntity(pub Option<Entity>);

0 comments on commit 9348e31

Please sign in to comment.