Skip to content

Conversation

@kfc35
Copy link
Contributor

@kfc35 kfc35 commented Jan 1, 2026

Objective

  • Fixes 22305

Solution

Summary: Add a feature flag to the auto navigation code that depends on bevy_camera and bevy_ui

  • I separated out some code from directional_navigation.rs into two separate files (first commit):
  1. auto_directional_navigation.rs which contains the code that uses bevy_ui and bevy_camera
  2. navigator.rs which contains structs and functions that are used by both auto_directional_navigation and the manual navigation code in directional_navigation.rs.
  • directional_navigation.rs still contains the main DirectionalNavigationPlugin, the map, and the DirectionalNavigation System Param that users should use
  • added a new feature flag called auto_nav to basically feature gate the logic that auto_directional_navigation.rs to the main navigator system param, and use that flag where appropriate. That’s the work contained in the second commit.

I do not know if I’m 100% happy with how I refactored, especially the names of the new files and everything, so please feel free to suggest other names if desired. Just getting this out relatively quickly since I had been the most recent person to change things, but I’m not tied to this approach.

TODO

  • update release notes

Testing

  • To ensure no regressions, I tested the directional navigation examples and both work as they did before.
    cargo run --example directional_navigation
    cargo run --example auto_directional_navigation --features=“auto_nav"

@jbuehler23
Copy link
Contributor

I'm actually not sure how I feel about adding another feature flag, though I can't think of an alternative solution right now until I get stuck in with these changes! My worry is that we are just adding to the already long list of them - but that's a different story.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 1, 2026

You added a new feature but didn't update the readme. Please run cargo run -p build-templated-pages -- update features to update it, and commit the file change.

@kfc35
Copy link
Contributor Author

kfc35 commented Jan 1, 2026

I'm actually not sure how I feel about adding another feature flag, though I can't think of an alternative solution right now until I get stuck in with these changes! My worry is that we are just adding to the already long list of them - but that's a different story.

Yeah, I’m definitely not tied to this approach! At the very least, this PR shows where the separation happens so the first commit can be used to branch off to a different approach if that helps you understand the state of things. I can also try moving the auto directional stuff into bevy_ui like @brianreavis did in #22309

@kfc35 kfc35 force-pushed the 22305_separate_input_focus_and_ui branch from cc53c5b to f86a8aa Compare January 1, 2026 15:55
@github-actions
Copy link
Contributor

github-actions bot commented Jan 1, 2026

You added a new feature but didn't update the readme. Please run cargo run -p build-templated-pages -- update features to update it, and commit the file change.

@kfc35
Copy link
Contributor Author

kfc35 commented Jan 1, 2026

Closing this in favor of #22340
If this feature approach is preferable, this can be reopened

@kfc35 kfc35 closed this Jan 1, 2026
github-merge-queue bot pushed a commit that referenced this pull request Jan 6, 2026
…eature flag needed (#22340)

# Objective

- Fixes #22305 
- Avoid feature flagging 

## Solution

Taking inspiration from #22309 and building off of #22333, this moves
the auto directional navigation to `bevy_ui` and creates a new system
parameter to be used when including automatic navigation.

- directional_navigation.rs of `bevy_input_focus` still contains the
`DirectionalNavigation` system parameter, but it now only contains logic
to do manual navigation. The `DirectionalNavigationPlugin` is still
there, as well as the manual edge map.
- I separated out some code from directional_navigation.rs into two
separate files:
1) directional_navigation.rs in `bevy_ui` which contains the automatic
navigation code. There is a new system parameter now,
`AutoDirectionalNavigator`, that wraps the `DirectionalNavigation`
system parameter and does automatic navigation if manual navigation
fails.
2) navigator.rs which contains some structs and functions that are used
by both the automatic navigation system and the manual navigation code
in directional_navigation.rs. This particular refactoring wasn’t
particularly necessary, but I feel like the code is little more cleaner
for it… I can revert this change if desired

If you think a feature is better for this, then let me know whether
#22333 should be considered instead.

If this gets merged, I’ll open up a pull request against `release-0.18`
to update the release notes, basically saying that users who want to
leverage `AutoDirectionalNavigation` need to use the
`AutoDirectionalNavigator` instead of the existing
`DirectionalNavigation` system param.

## Testing

To ensure no regressions, I tested the directional navigation examples
and both work as they did before.
`cargo run --example directional_navigation` - uses the existing
`DirectionalNavigation` system parameter
`cargo run --example auto_directional_navigation` - uses the new
`AutoDirectionalNavigator` system parameter
cart pushed a commit that referenced this pull request Jan 8, 2026
…eature flag needed (#22340)

- Fixes #22305
- Avoid feature flagging

Taking inspiration from #22309 and building off of #22333, this moves
the auto directional navigation to `bevy_ui` and creates a new system
parameter to be used when including automatic navigation.

- directional_navigation.rs of `bevy_input_focus` still contains the
`DirectionalNavigation` system parameter, but it now only contains logic
to do manual navigation. The `DirectionalNavigationPlugin` is still
there, as well as the manual edge map.
- I separated out some code from directional_navigation.rs into two
separate files:
1) directional_navigation.rs in `bevy_ui` which contains the automatic
navigation code. There is a new system parameter now,
`AutoDirectionalNavigator`, that wraps the `DirectionalNavigation`
system parameter and does automatic navigation if manual navigation
fails.
2) navigator.rs which contains some structs and functions that are used
by both the automatic navigation system and the manual navigation code
in directional_navigation.rs. This particular refactoring wasn’t
particularly necessary, but I feel like the code is little more cleaner
for it… I can revert this change if desired

If you think a feature is better for this, then let me know whether

If this gets merged, I’ll open up a pull request against `release-0.18`
to update the release notes, basically saying that users who want to
leverage `AutoDirectionalNavigation` need to use the
`AutoDirectionalNavigator` instead of the existing
`DirectionalNavigation` system param.

To ensure no regressions, I tested the directional navigation examples
and both work as they did before.
`cargo run --example directional_navigation` - uses the existing
`DirectionalNavigation` system parameter
`cargo run --example auto_directional_navigation` - uses the new
`AutoDirectionalNavigator` system parameter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants