@@ -16,7 +16,6 @@ pub fn ui_z_system(
16
16
. iter ( )
17
17
. map ( |e| ( e, UI_BASE_DEPTH ) )
18
18
. collect :: < Vec < ( Entity , f32 ) > > ( ) ;
19
- node_stack. reverse ( ) ;
20
19
while let Some ( ( node, parent_global_z) ) = node_stack. pop ( ) {
21
20
current_global_z += UI_Z_STEP ;
22
21
let local_z = current_global_z - parent_global_z;
@@ -58,7 +57,18 @@ mod tests {
58
57
let mut commands = Commands :: default ( ) ;
59
58
commands. set_entity_reserver ( world. get_entity_reserver ( ) ) ;
60
59
61
- commands. spawn ( node_with_transform ( "0" ) ) ;
60
+ commands
61
+ . spawn ( node_without_transform ( "0" ) )
62
+ . with_children ( |parent| {
63
+ parent
64
+ . spawn ( node_with_transform ( "0-0" ) )
65
+ . with_children ( |_parent| ( ) ) ;
66
+ parent
67
+ . spawn ( node_with_transform ( "0-1" ) )
68
+ . with_children ( |parent| {
69
+ parent. spawn ( node_with_transform ( "0-1-0" ) ) ;
70
+ } ) ;
71
+ } ) ;
62
72
63
73
commands
64
74
. spawn ( node_with_transform ( "1" ) )
@@ -83,19 +93,8 @@ mod tests {
83
93
} ) ;
84
94
parent. spawn ( node_with_transform ( "1-3" ) ) ;
85
95
} ) ;
96
+ commands. spawn ( node_with_transform ( "2" ) ) ;
86
97
87
- commands
88
- . spawn ( node_without_transform ( "2" ) )
89
- . with_children ( |parent| {
90
- parent
91
- . spawn ( node_with_transform ( "2-0" ) )
92
- . with_children ( |_parent| ( ) ) ;
93
- parent
94
- . spawn ( node_with_transform ( "2-1" ) )
95
- . with_children ( |parent| {
96
- parent. spawn ( node_with_transform ( "2-1-0" ) ) ;
97
- } ) ;
98
- } ) ;
99
98
commands. apply ( & mut world, & mut resources) ;
100
99
101
100
let mut schedule = Schedule :: default ( ) ;
@@ -110,23 +109,23 @@ mod tests {
110
109
. collect :: < Vec < ( String , u32 ) > > ( ) ;
111
110
actual_result. sort_unstable_by_key ( |( name, _) | name. clone ( ) ) ;
112
111
let expected_result = vec ! [
113
- ( "0" . to_owned ( ) , 1 ) , // total_depth 1
114
- ( "1 " . to_owned( ) , 2 ) , // total_depth 2
115
- ( "1-0 " . to_owned( ) , 1 ) , // total_depth 3
116
- ( "1-0 -0" . to_owned( ) , 1 ) , // total_depth 4
117
- // 1-0-1 has no transform total_depth 5
118
- ( "1-0-2 " . to_owned( ) , 3 ) , // total_depth 6
119
- ( "1-1 " . to_owned( ) , 5 ) , // total_depth 7
120
- // 1-2 has no transform total_depth 8
121
- ( "1-2-0 " . to_owned( ) , 1 ) , // total_depth 9
122
- ( "1-2- 1" . to_owned( ) , 2 ) , // total_depth 10
123
- ( " 1-2-2" . to_owned ( ) , 3 ) , // total_depth 11
124
- ( "1-2-3 " . to_owned( ) , 4 ) , // total_depth 12
125
- ( "1-3 " . to_owned( ) , 11 ) , // total_depth 13
126
- // 2 has no transform total_depth 14
127
- ( "2-0 " . to_owned( ) , 1 ) , // total_depth 15
128
- ( "2-1 " . to_owned( ) , 2 ) , // total_depth 16
129
- ( "2-1-0 " . to_owned( ) , 1 ) , // total_depth 17
112
+ // 0 has no transform total_depth 1
113
+ ( "0-0 " . to_owned( ) , 1 ) , // total_depth 2
114
+ ( "0-1 " . to_owned( ) , 2 ) , // total_depth 3
115
+ ( "0-1 -0" . to_owned( ) , 1 ) , // total_depth 4
116
+ ( "1" . to_owned ( ) , 5 ) , // total_depth 5
117
+ ( "1-0" . to_owned( ) , 1 ) , // total_depth 6
118
+ ( "1-0-0 " . to_owned( ) , 1 ) , // total_depth 7
119
+ // 1-0-1 has no transform total_depth 8
120
+ ( "1-0-2 " . to_owned( ) , 3 ) , // total_depth 9
121
+ ( "1-1" . to_owned( ) , 5 ) , // total_depth 10
122
+ // 1-2 has no transform total_depth 11
123
+ ( "1-2-0 " . to_owned( ) , 1 ) , // total_depth 12
124
+ ( "1-2-1 " . to_owned( ) , 2 ) , // total_depth 13
125
+ ( "1-2-2" . to_owned ( ) , 3 ) , // total_depth 14
126
+ ( "1-2-3 " . to_owned( ) , 4 ) , // total_depth 15
127
+ ( "1-3 " . to_owned( ) , 11 ) , // total depth 16
128
+ ( "2" . to_owned( ) , 17 ) , // total_depth 17
130
129
] ;
131
130
assert_eq ! ( actual_result, expected_result) ;
132
131
}
0 commit comments