Skip to content

Commit caee55c

Browse files
authored
Update Automatic Directional Navigation Release Notes (due to dependency rearrangement) (#22344)
# Objective - Documenting changes to resolve #22305 - Update the release notes as a result of #22340 This is dependent on merging #22340 into 0.18! **This is pointing to merge into release-0.18.0**, not main @jbuehler23 FYI
1 parent c23a8e2 commit caee55c

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

release-content/release-notes/automatic_directional_navigation.md

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
22
title: Automatic Directional Navigation
33
authors: ["@jbuehler23"]
4-
pull_requests: [21668]
4+
pull_requests: [21668, 22340]
55
---
66

7-
Bevy now supports **automatic directional navigation graph generation** for UI elements! No more tedious manual wiring of navigation connections for your menus and UI screens.
7+
Bevy now supports **automatic directional navigation** for UI elements! No more tedious manual wiring of navigation connections for your menus and UI screens.
88

99
## What's New?
1010

1111
Previously, creating directional navigation for UI required manually defining every connection between focusable elements using `DirectionalNavigationMap`. For dynamic UIs or complex layouts, this was time-consuming and error-prone.
1212

13-
Now, you can simply add the `AutoDirectionalNavigation` component to your UI entities, and Bevy will automatically compute navigation connections based on spatial positioning. The system intelligently finds the nearest neighbor in each of the 8 compass directions (North, Northeast, East, etc.), considering:
13+
Now, you can simply add the `AutoDirectionalNavigation` component to your UI entities, and Bevy will automatically compute navigation connections based on spatial positioning. The system parameter intelligently finds the nearest neighbor in each of the 8 compass directions (North, Northeast, East, etc.), considering:
1414

1515
- **Distance**: Closer elements are preferred
1616
- **Alignment**: Elements that are more directly in line with the navigation direction are favored
@@ -29,7 +29,17 @@ commands.spawn((
2929
));
3030
```
3131

32-
That's it! The `DirectionalNavigationPlugin` includes a system that automatically maintains the navigation graph as your UI changes.
32+
To leverage automatic navigation, use the `AutoDirectionalNavigator` system parameter instead of the `DirectionalNavigation` system parameter:
33+
34+
```rust
35+
fn my_navigation_system(mut auto_directional_navigator: AutoDirectionalNavigator) {
36+
// ...
37+
auto_directional_navigator.navigate(CompassOctant::East);
38+
// ...
39+
}
40+
```
41+
42+
That's it! The `DirectionalNavigationPlugin` will set up the resources that `AutoDirectionalNavigator` uses to function.
3343

3444
### Configuration
3545

@@ -68,24 +78,34 @@ This is a non-breaking change. Existing manual navigation setups continue to wor
6878

6979
If you want to convert existing manual navigation to automatic:
7080

71-
**Before:**
72-
7381
```rust
82+
// 0.17
7483
// Manually define all edges
7584
directional_nav_map.add_looping_edges(&row_entities, CompassOctant::East);
7685
directional_nav_map.add_edges(&column_entities, CompassOctant::South);
7786
// ... repeat for all rows and columns
78-
```
7987

80-
**After:**
88+
// Use the DirectionalNavigation SystemParam to navigate in your system
89+
fn my_navigation_system(mut directional_navigation: DirectionalNavigation) {
90+
// ...
91+
directional_navigation.navigate(CompassOctant::East);
92+
// ...
93+
}
8194

82-
```rust
95+
// 0.18
8396
// Just add the component to your UI entities
8497
commands.spawn((
8598
Button,
8699
Node { /* ... */ },
87100
AutoDirectionalNavigation::default(),
88101
));
102+
103+
// Use the AutoDirectionalNavigator SystemParam to navigate in your system
104+
fn my_navigation_system(mut auto_directional_navigator: AutoDirectionalNavigator) {
105+
// ...
106+
auto_directional_navigator.navigate(CompassOctant::East);
107+
// ...
108+
}
89109
```
90110

91-
Note: The automatic navigation system requires entities to have position and size information (`ComputedNode` and `UiGlobalTransform` for `bevy_ui` entities).
111+
Note: Automatic navigation requires entities to have position and size information (`ComputedNode` and `UiGlobalTransform` for `bevy_ui` entities).

0 commit comments

Comments
 (0)