Repository navigation
Expand file tree
/
Copy pathremote_inspector.rs
More file actions
122 lines (116 loc) · 3.67 KB
/
Copy pathremote_inspector.rs
File metadata and controls
122 lines (116 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//! Shows the `bevy_inspector` entity tree and details panels inspecting a separate running app
//! over the Bevy Remote Protocol.
//!
//! Run the app to inspect in one terminal:
//! ```bash
//! cargo run --example server --features="bevy_remote"
//! ```
//!
//! Add the `bevy_debug_stepping` feature to the server to enable stepping through systems using controls on the inspector.
//!
//! Then run this example in another terminal:
//! ```bash
//! cargo run --example remote_inspector --features="bevy_inspector,bevy_remote_client"
//! ```
//!
//! The address defaults to `127.0.0.1:15702` and can be overridden with the `BRP_HOST` and
//! `BRP_PORT` environment variables, or changed in the connection bar at the top.
use bevy::{
feathers::{
controls::{FeathersPane, FeathersSplitPane, FeathersSplitPaneHandle},
dark_theme::create_dark_theme,
theme::UiTheme,
FeathersPlugins,
},
inspector::{
connection_panel::connection_panel,
details_panel::details_panel,
entity_tree::{entity_tree_panel, InspectorUi},
remote::stepping::stepping_controls,
InspectorPlugin, InspectorSources,
},
prelude::*,
remote::http::{DEFAULT_PORT, DEFAULT_RENDER_PORT},
ui_widgets::split_pane_self_update,
};
fn main() {
App::new()
.add_plugins((DefaultPlugins, FeathersPlugins, InspectorPlugin))
.insert_resource(UiTheme(create_dark_theme()))
.insert_resource(build_inspector_sources())
.add_systems(Startup, (camera.spawn(), inspector_ui.spawn()))
.run();
}
fn build_inspector_sources() -> InspectorSources {
let host = std::env::var("BRP_HOST").unwrap_or_else(|_| "127.0.0.1".to_string());
let main_port = std::env::var("BRP_PORT")
.ok()
.and_then(|port| port.parse().ok())
.unwrap_or(DEFAULT_PORT);
let render_port = std::env::var("BRP_RENDER_PORT")
.ok()
.and_then(|port| port.parse().ok())
.unwrap_or(DEFAULT_RENDER_PORT);
InspectorSources::remote(host, main_port, render_port)
}
fn camera() -> impl Scene {
bsn! {
Name("Camera")
Camera2d
}
}
fn inspector_ui() -> impl Scene {
bsn! {
InspectorUi
Name::new("Inspector")
Node {
position_type: PositionType::Absolute,
width: percent(100),
height: percent(100),
padding: px(12),
flex_direction: FlexDirection::Column,
align_items: AlignItems::FlexStart,
row_gap: px(8),
}
Children [
Node {
flex_direction: FlexDirection::Row,
align_items: AlignItems::Center,
flex_wrap: FlexWrap::Wrap,
column_gap: px(16),
row_gap: px(8),
}
Children [
@connection_panel()
--
@stepping_controls()
]
--
@FeathersSplitPane
Node {
width: px(720),
max_height: percent(100),
}
on(split_pane_self_update)
Children [
@FeathersPane { @size: 1.0, @min_size: 220.0 }
Children [
@entity_tree_panel()
Node {
width: Val::Auto,
}
]
--
@FeathersSplitPaneHandle
--
@FeathersPane { @size: 2.0, @min_size: 240.0 }
Children [
@details_panel()
Node {
width: Val::Auto,
}
]
]
]
}
}