1
1
use bevy:: {
2
2
ecs:: { query:: QueryFilter , system:: RunSystemOnce } ,
3
3
prelude:: * ,
4
- render:: { camera :: CameraProjection , view:: RenderLayers } ,
4
+ render:: view:: RenderLayers ,
5
5
} ;
6
6
7
7
use bevy_editor_pls_core:: editor_window:: { EditorWindow , EditorWindowContext } ;
8
- use bevy_inspector_egui:: { bevy_inspector:: hierarchy:: SelectedEntities , egui} ;
9
- use transform_gizmo_bevy:: { EnumSet , GizmoMode } ;
8
+ use bevy_inspector_egui:: egui;
10
9
use transform_gizmo_bevy:: GizmoTarget ;
10
+ use transform_gizmo_bevy:: { EnumSet , GizmoMode } ;
11
11
12
12
use crate :: {
13
- cameras:: { ActiveEditorCamera , CameraWindow , EditorCamera , EDITOR_RENDER_LAYER } ,
13
+ cameras:: { EditorCamera , EDITOR_RENDER_LAYER } ,
14
14
hierarchy:: HierarchyWindow ,
15
15
} ;
16
16
17
17
pub struct GizmoState {
18
+ /// If [false], doesn't show any gizmos
18
19
pub camera_gizmo_active : bool ,
19
- /// TODO: Take these settings into account
20
+ /// Synced with the [transform_gizmo_bevy::GizmoOptions] resource
20
21
pub gizmo_modes : EnumSet < GizmoMode > ,
21
22
}
22
23
@@ -38,17 +39,17 @@ impl EditorWindow for GizmoWindow {
38
39
39
40
fn ui ( _world : & mut World , _cx : EditorWindowContext , ui : & mut egui:: Ui ) {
40
41
ui. label ( "Gizmos can currently not be configured" ) ;
41
- // could definitely change some settings here in the future
42
+ // could definitely change some settings here in the future
42
43
}
43
44
44
- /// Called every frame (hopefully), could this invariant (namely being called every frame) be documented,
45
- /// ideally in the [EditorWindow] trait?
45
+ /// Called every frame (hopefully), could this invariant (namely being called every frame) be documented,
46
+ /// ideally in the [EditorWindow] trait?
46
47
fn viewport_toolbar_ui ( world : & mut World , cx : EditorWindowContext , _ui : & mut egui:: Ui ) {
47
48
let gizmo_state = cx. state :: < GizmoWindow > ( ) . unwrap ( ) ;
48
49
49
- // syncs the [GizmoOptions] resource with the current state of the gizmo window
50
- let mut gizmo_options = world. resource_mut :: < transform_gizmo_bevy:: GizmoOptions > ( ) ;
51
- gizmo_options. gizmo_modes = gizmo_state. gizmo_modes ;
50
+ // syncs the [GizmoOptions] resource with the current state of the gizmo window
51
+ let mut gizmo_options = world. resource_mut :: < transform_gizmo_bevy:: GizmoOptions > ( ) ;
52
+ gizmo_options. gizmo_modes = gizmo_state. gizmo_modes ;
52
53
53
54
if gizmo_state. camera_gizmo_active {
54
55
/// Before [hydrate_gizmos] and [deconstruct_gizmos] are run, this system resets the state of all entities that have a [EntityShouldShowGizmo] component.
@@ -68,8 +69,12 @@ impl EditorWindow for GizmoWindow {
68
69
entities : Query < Entity , ( With < EntityShouldShowGizmo > , Without < GizmoTarget > ) > ,
69
70
) {
70
71
for entity in entities. iter ( ) {
71
- trace ! ( "Hydrating a gizmo on entity {:?} because it is selected" , entity) ;
72
- // TODO: Maybe change the exact gizmo target instance instead of using default? should this load from some config?
72
+ trace ! (
73
+ "Hydrating a gizmo on entity {:?} because it is selected" ,
74
+ entity
75
+ ) ;
76
+ // implicitly assumes it is the only gizmo system in the world,
77
+ // otherwise setting [GizmoTarget].is_focussed may be necessary
73
78
commands. entity ( entity) . insert ( GizmoTarget :: default ( ) ) ;
74
79
}
75
80
}
0 commit comments