Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dothanhtrung/bevy-text-edit
Bevy plugin for easier input text
https://github.com/dothanhtrung/bevy-text-edit
bevy bevy-plugin game-development rust
Last synced: 3 months ago
JSON representation
Bevy plugin for easier input text
- Host: GitHub
- URL: https://github.com/dothanhtrung/bevy-text-edit
- Owner: dothanhtrung
- License: other
- Created: 2024-06-10T15:43:24.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2024-08-13T04:09:27.000Z (5 months ago)
- Last Synced: 2024-09-27T07:03:25.863Z (4 months ago)
- Topics: bevy, bevy-plugin, game-development, rust
- Language: Rust
- Homepage: https://gitlab.com/kimtinh/bevy-text-edit
- Size: 58.6 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
bevy_text_edit
==============[![crates.io](https://img.shields.io/crates/v/bevy_text_edit)](https://crates.io/crates/bevy_text_edit)
[![docs.rs](https://docs.rs/bevy_text_edit/badge.svg)](https://docs.rs/bevy_text_edit)
[![dependency status](https://deps.rs/repo/gitlab/kimtinh/bevy-text-edit/status.svg)](https://deps.rs/repo/gitlab/kimtinh/bevy-text-edit)
[![pipeline status](https://gitlab.com/kimtinh/bevy-text-edit/badges/master/pipeline.svg)](https://gitlab.com/kimtinh/bevy-text-edit/-/commits/master)![](examples/text_edit.mp4)
Quickstart
----------### Plugin
Add plugin `TextEditPlugin` to the app and define which states it will run in:
```rust
#[derive(Clone, Debug, Default, Eq, PartialEq, Hash, States)]
enum GameState {
#[default]
Menu,
}fn main() {
App::new()
.add_plugins(DefaultPlugins)
// Add the plugin
.add_plugins(TextEditPlugin::new(vec![GameState::Menu]))
.run;
}
```If you don't care to game state and want to always run input text, use `TextEditPluginNoState`:
```rust
fn main() {
App::new()
.add_plugins(DefaultPlugins)
// Add the plugin
.add_plugins(TextEditPluginNoState)
.add_systems(Startup, setup)
.run();
}
```### Component
Insert component `TextEditable` and `Interaction` into any text entity that needs to be editable:
```rust
commands.spawn((
TextEditable::default(), // Mark text is editable
Interaction::None, // Mark entity is interactable
TextBundle::from_section(
"Input Text 1",
TextStyle::default(),
),
));
```Only text that is focused by clicking gets keyboard input.
It is also possible to limit which characters are allowed to enter through `filter_in` and `filter_out` attribute. Regex is supported:
```rust
commands.spawn((
TextEditable {
filter_in: vec!["[0-9]".into(), " ".into()], // Only allow number and space
filter_out: vec!["5".into()], // Ignore number 5
},
Interaction::None,
TextBundle::from_section(
"Input Text 1",
TextStyle::default(),
),
));
```License
-------Please see [LICENSE](./LICENSE).
Compatible Bevy Versions
------------------------| bevy | bevy_text_edit |
|------|------------------------------|
| 0.14 | 0.1-0.3, branch `master` |
| 0.13 | 0.0.1-0.0.5 |